Re: File contents
On Mon, May 06, 2002 at 12:32:17PM +0200, Craig wrote:
> Could someone help with changing file contents in a specific directory
> with a number of files.
> I used greg to extract the criteria but need something to change it.
perl is the ideal tool to do this.
in particular, see the perlrun man page for details about the -i option.
perl -p -i.bak -e 's/foo/bar/g' *
will change all occurences of foo to bar in all files in the current
directory, first saving the original file(s) as .bak.
the perl script can be as simple or as complex as you need it to be. it
craig sanders <email@example.com>
Fabricati Diem, PVNC.
-- motto of the Ankh-Morpork City Watch
To UNSUBSCRIBE, email to firstname.lastname@example.org
with a subject of "unsubscribe". Trouble? Contact email@example.com