[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

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.

cheers, robt


csj wrote:
> 
> 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
> 
> --
> Just testing this signature thing!
> 
> --
> To UNSUBSCRIBE, email to debian-user-request@lists.debian.org
> with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org



Reply to: