Re: Command line search and replace
csj schrieb:
> 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 <john@dhh.gt.org>, Michal
> <frankie@tristvrte.sk>, und eechi von akusyumi
> <vinauser@netvigator.com> 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
try this:
find . -name *.txt | xargs perl -pi -e 's/foo/boo/g;'
joachim
Reply to: