[NTLUG:Discuss] Linux script question

Bug Hunter bughuntr at one.ctelcom.net
Mon Jun 16 13:53:41 CDT 2003


On Mon, 16 Jun 2003, Chris Cox wrote:

> Pervaz Allaudin wrote:
> > OK I have another linux command question.
> > 
> > I have multiple files in multiple dirs. under a dir. from which I want 
> > to replace a word and then written back; Either in the same files or 
> > another dir. as root.
> > 
> > I got till
> > 
> > find src -iname *.ext | xargs sed /oldtext/newtext/
> > 

  for a single file:

  sed /oldtext/newtext/ filename > filename.newfile
  rm -f filename
  mv filename.newfile filename

  
in bash

  for i in /dirname/*
do
 sed /oldtext/newtext/ $i > $i.newfile
 rm -f $i.newfile
 mv $i.newfile $i
done

  This was given to me by a fellow named Richard a while back. :)

bug





More information about the Discuss mailing list