[Sorry] Re: Command line search and replace
sorry guys,
I actually didn't intend to bounce that message -- I had the focus on
the wrong X window while typing something unrelated, which obviously
turned out to be a valid mutt key sequence...
Anyway, thanks for your effort :-) (ok, ok, I'll shut up now...)
On Tue, Jan 09, 2001 at 02:33:34PM +0100, bounce-debian-user=e.pfeifer=science-computing.de@lists.debian.org wrote:
> 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
>
>
> --
> To UNSUBSCRIBE, email to debian-user-request@lists.debian.org
> with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
>
--
Erdmut Pfeifer
science+computing gmbh
-- Bugs come in through open windows. Keep Windows shut! --
Reply to: