At Wed, 17 Sep 2003 11:50:15 -0800, Ken Irving wrote: > > On Wed, Sep 17, 2003 at 04:22:15AM -0700, Ric Otte wrote: > > On Wed, Sep 17, 2003 at 11:40:31AM +0100, Karsten M. Self wrote: > > > on Wed, Sep 17, 2003 at 08:08:26AM +0800, csj ([EMAIL PROTECTED]) wrote: > > > > At Tue, 16 Sep 2003 17:08:51 +0200, > > > > Matthias Czapla wrote: > > > > > > > > > > On Tue, Sep 16, 2003 at 07:39:39AM -0700, Ric Otte wrote: > > > > > > Hi, I would like to run all of the files in some directories > > > > > > through sed, in order to edit the files. I can do it for > > > > > > individual files by typing: cat filename|sed command>filename > > > > > > But that requires me to run that command for each file. I > > > > > > was wondering if anyone could 1) give me a reference to a > > > > > > simple bash tutorial that will explain how to set up a script > > > > > > to do things like this, > > > > > > > > > > http://www.tldp.org/HOWTO/Bash-Prog-Intro-HOWTO.html > > > > > > > > > > > and 2) tell me how to do it. > > > > > > > > > > for f in *; do tmp=`tempfile`; cat $f | sed command > $tmp ; mv $tmp $f; done > > > > > > > > Is there anything intrinsically wrong with: > > > > > > > > find directory -name "*.foo" | xargs sed -i -f sed_script > > > > > Perl also provides the -i option to change files in place and optionally > save a backup copy, e.g., > > $ perl -i -pe 'command' *.foo > $ perl -i.bak -pe 'command' *.foo
And so too can sed: -i[suffix], --in-place[=suffix] edit files in place (makes backup if extension supplied) -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]