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

Re: Multible search and replace?



On Wed, 8 Jan 1997, Chad Zimmerman wrote:

> Was just wondering if there is a package out that does multiple file
> search and replaces? I have to go through my main html directory and
> make a lot of repetive changes. Was wondering if there was a package
> or a perl script laying arround to do this. Would same me the time of
> writing one up.

sounds like a job for an ed script embedded within a sh script :-)

something like:

------cut here-----
#! /bin/sh

for i in *.html ; do 
cat <<__EOF__ | ed -s $i
s/SEARCH/REPLACE/g
(and/or any other ed commands you might need here.  just about anything
you can do in vi you can do here)
wq
__EOF__
done
------cut here-----

does pretty much the same job as sed but without the need for messing about
with temporary files.

note, the "wq" as the last line of the ed script is important.  that's the
familiar vi/ed "write & quit" command :-)


craig


--
TO UNSUBSCRIBE FROM THIS MAILING LIST: e-mail the word "unsubscribe" to
debian-user-REQUEST@lists.debian.org . Trouble? e-mail to Bruce@Pixar.com


Reply to: