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

Re: Command line search and replace



on Mon, Jan 08, 2001 at 05:53:51PM -0500, Jonathan D. Proulx (jon@ai.mit.edu) wrote:
> On Tue, Jan 09, 2001 at 12:54:34AM +0800, csj wrote:
> 
> :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
> 
> My vote for most elegant:
> 
> find . -name *.txt -exec sed s/foo/boo/g {} \;
>                 {} refers to file found  ^  ^must have \; to terminate
> 					     -exec

This solution doesn't create an output file for each input file, as
requested.

-- 
Karsten M. Self <kmself@ix.netcom.com>    http://kmself.home.netcom.com/
  What part of "Gestalt" don't you understand?      There is no K5 cabal
   http://gestalt-system.sourceforge.net/        http://www.kuro5hin.org

Attachment: pgpq2HaSGvZ8m.pgp
Description: PGP signature


Reply to: