[plug] grep task?

Cameron Patrick cameron at patrick.wattle.id.au
Sat Nov 22 14:16:43 WST 2003


On Sat, Nov 22, 2003 at 02:02:57PM +0800, John Knight wrote:

| Are there any greppers who could could tell me how to get a certain task 
| out of the way? I've got to go through several directories of html pages 
| and change an email address in them.
| 
| I'd be wanting the script to:
| 1. search through the files for "anarchist_tomato at hotmail.com"
| 2. if found, replace with "entombednerds at yahoo.co.uk"
| 3. report the name of the file that's just been changed.
| 
| Is that possible?

Not using grep, but sed will do it:

for file in *.html; do
	<${file} sed 's/anarchist at blah/entombednerds at blah/g' >${file}.new && mv ${file}.new ${file}
done

Cameron.

_______________________________________________
plug mailing list
plug at plug.linux.org.au
http://mail.plug.linux.org.au/cgi-bin/mailman/listinfo/plug


More information about the plug mailing list