Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 18 Dec 2001 03:39:00 -0800
From:      Matthew Hunt <mph@astro.caltech.edu>
To:        Erik Trulsson <ertr1013@student.uu.se>
Cc:        Jon Molin <Jon.Molin@resfeber.se>, Anthony Atkielski <anthony@freebie.atkielski.com>, FreeBSD Questions <freebsd-questions@FreeBSD.ORG>
Subject:   Re: Command to make modifications on multiple files
Message-ID:  <20011218033900.A99742@wopr.caltech.edu>
In-Reply-To: <20011218110256.GA1464@student.uu.se>; from ertr1013@student.uu.se on Tue, Dec 18, 2001 at 12:02:56PM %2B0100
References:  <007701c187af$8b564d40$0a00000a@atkielski.com> <3C1F1C07.79B38414@resfeber.se> <20011218110256.GA1464@student.uu.se>

next in thread | previous in thread | raw e-mail | index | archive | help
On Tue, Dec 18, 2001 at 12:02:56PM +0100, Erik Trulsson wrote:

> [Warning! Untested code follows!]

A-yup.

> perl -pie 's/searchregex/replacestring/g' file1 file2 file3 

You need to split the options:

perl -pi -e 's/searchregex/replacestring/g' file1 file2 file3

The -i option takes an optional argument, which is a string like ".bak"
which tells it to store backup copies of the input files in file1.bak, etc.
In your example, it would produce backup copies "file1e", "file2e", and
"file3e".  But it would also bomb because the -e option was missing.

A novice probably should, in fact, use the backup feature, and say
something like:

perl -pi.bak -e 's/searchregex/replacestring/g' file1 file2 file3

[Warning! Preaching not practiced! Untested code precedes!]

-- 
Matthew Hunt <mph@astro.caltech.edu> * Stay close to the Vorlon.
http://www.pobox.com/~mph/           *

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-questions" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20011218033900.A99742>