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 <firstname.lastname@example.org>
Fabricati Diem, PVNC.
-- motto of the Ankh-Morpork City Watch
To UNSUBSCRIBE, email to email@example.com
with a subject of "unsubscribe". Trouble? Contact firstname.lastname@example.org