[lug] simple text editing problem
Tkil
tkil at scrye.com
Thu Aug 22 12:55:44 MDT 2002
>>>>> "MD" == Michael Deck <deckm at cleansoft.com> writes:
MD> Have you considered sed? What I do is to write a little sed script like
MD> s/TextToReplace/Replacement/g
MD> s/OtherTextReplace/OtherReplacement/g
MD> Then I created a shell script "sedexec"
MD> #!/bin/bash
MD> echo ${1}
MD> cp ${1} ${1}.orig
MD> sed -f ~/sedscript ${1}.orig > ${1}
MD> That way if something goes wrong I have the original file.
MD> Finally
MD> find . -name 'filter' -exec ./sedexec {} \;
MD> man sed and man find for details.
perl has some of this stuff built-in, especially the "-i" flag:
find . -name '*.whatever' -print0 | xargs -0 perl -i~ -plwe 's/foo/bar/g'
But note that this doesn't offer the "interactive" replacement that
the original poster requested...
t.
More information about the LUG
mailing list