[Gllug] Batch Text Replacement

Tethys sta296 at astradyne.co.uk
Mon Oct 29 08:50:33 UTC 2007


--------

"Henry Gilbert" writes:

>Not my server and not even a dedicated server.
>I am probably confined to only FTP.

Then you'll have to download them, edit them locally and upload
them again. Of course that process could be scripted...

>I was really looking for something more GUI

Why?

>What would be the regex (or even the "sed" command) that would strip
>any occurrence of the string ' style="blah blah blah' from a group of
>html files?

	for file in *.html
	do
		tmp=$(mktemp "$file.XXXXXXX")
		sed 's/ *style="[^"]*"//' "$file" > "tmp" && mv "$tmp" "$file"
	done

There are a few pathological cases it won't catch (like escaped
double quotes in the style string), but you're unlikely to find
them in the real world.

Tet
-- 
Gllug mailing list  -  Gllug at gllug.org.uk
http://lists.gllug.org.uk/mailman/listinfo/gllug




More information about the GLLUG mailing list