[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Edlug Archive Mar 2004 ]

Re: [edlug] Global Search and Replace



Dick Middleton wrote:
> On the same lines you could do:
> 
> find . -name '*.html' -exec sed 's.....' \;
> 
> I've not tried it though

The problem is that sed doesn't edit the file in place - it just
outputs the filtered version to stdout.  So what I was thinking of
as the "obvious" solution was:

export A='</body>'
export B='whatever
it
was
</body>'
TEMP=/some/secure/path/temp.html
for	EACH
in	$(find . -name *.html)
do	sed "s/$A/$B/" $EACH > $TEMP
	cat $TEMP > $EACH
done
rm $TEMP

But once it gets that long it's worth thinking about the perl
one-liner solution... though as it happens I also have ssed
installed, which can do it in-place.
-- 
JBR
Ankh kak! (Ancient Egyptian blessing)

-
----------------------------------------------------------------------
You can find the EdLUG mailing list FAQ list at:
http://www.edlug.org.uk/list_faq.html



This archive is kept by wibble@morpheux.org.DONTSPAMME
homepage