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

Re: Command line search and replace



On Tue, 9 Jan 2001 00:54:34 +0800
csj <csj@mindgate.net> 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

for i in `find . -name *.txt` ; do ...


--
Christoph Simon
ciccio@prestonet.com.br
---
^X^C
q
quit
:q
^C
end
x
exit
ZZ
^D
?
help
shit
.



Reply to: