[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

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
is perl.


craig sanders <cas@taz.net.au>

Fabricati Diem, PVNC.
 -- motto of the Ankh-Morpork City Watch

To UNSUBSCRIBE, email to debian-isp-request@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org

Reply to: