Re: Command line search and replace
then do this:
for i in `find . -name *.txt` ; do blah ; done
and make sure you know what you're doing.
> On Mon, Jan 08, 2001 at 12:56:45AM +0800, I wrote:
> > Is there a tool to do a search-and-replace from the command line?
> > Something along the lines of:
> > replace "string one" "string foo" files-to-process
> sed is it! Thanks to John <firstname.lastname@example.org>, Michal
> <email@example.com>, und eechi von akusyumi
> <firstname.lastname@example.org> for the replies. Now my problem is how to
> make sed recurse through directories. I managed to chain commands
> together as:
> for i in *.txt ; do mv $i $i.tmp ; sed s/foo/boo/g $i.tmp > $i ; done
> Can anybody comment on this little script? This appears to work, but
> may be inefficient. And it's one step removed from what I want,
> recursive processing. That is, to have sed process files in
> subdirectories of the current directory. I prefer something that can
> receive its input from find:
> find . -name *.txt
> Just testing this signature thing!
> To UNSUBSCRIBE, email to email@example.com
> with a subject of "unsubscribe". Trouble? Contact firstname.lastname@example.org