From owner-freebsd-questions Tue Dec 18 3:40:23 2001 Delivered-To: freebsd-questions@freebsd.org Received: from wopr.caltech.edu (wopr.caltech.edu [131.215.102.114]) by hub.freebsd.org (Postfix) with ESMTP id 7D2C337B417 for ; Tue, 18 Dec 2001 03:40:20 -0800 (PST) Received: (from mph@localhost) by wopr.caltech.edu (8.11.6/8.9.3) id fBIBd0V99800; Tue, 18 Dec 2001 03:39:00 -0800 (PST) (envelope-from mph) Date: Tue, 18 Dec 2001 03:39:00 -0800 From: Matthew Hunt To: Erik Trulsson Cc: Jon Molin , Anthony Atkielski , FreeBSD Questions Subject: Re: Command to make modifications on multiple files Message-ID: <20011218033900.A99742@wopr.caltech.edu> References: <007701c187af$8b564d40$0a00000a@atkielski.com> <3C1F1C07.79B38414@resfeber.se> <20011218110256.GA1464@student.uu.se> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5i In-Reply-To: <20011218110256.GA1464@student.uu.se>; from ertr1013@student.uu.se on Tue, Dec 18, 2001 at 12:02:56PM +0100 Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG 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 * 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