From owner-freebsd-isp Mon Dec 18 3:55:29 2000 From owner-freebsd-isp@FreeBSD.ORG Mon Dec 18 03:55:28 2000 Return-Path: Delivered-To: freebsd-isp@freebsd.org Received: from grok.example.net (a0g1355ly34tj.bc.hsia.telus.net [216.232.254.227]) by hub.freebsd.org (Postfix) with ESMTP id 5E09F37B400 for ; Mon, 18 Dec 2000 03:55:28 -0800 (PST) Received: by grok.example.net (Postfix, from userid 1000) id 00739213130; Mon, 18 Dec 2000 03:55:13 -0800 (PST) Date: Mon, 18 Dec 2000 03:55:13 -0800 From: Steve Reid To: Dave Wilson Cc: freebsd-isp@FreeBSD.ORG Subject: Re: Off topic - shell skills Message-ID: <20001218035513.A33674@grok.bc.hsia.telus.net> References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Mailer: Mutt 0.95.4i In-Reply-To: ; from Dave Wilson on Mon, Dec 18, 2000 at 11:33:10AM +0200 Sender: owner-freebsd-isp@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org On Mon, Dec 18, 2000 at 11:33:10AM +0200, Dave Wilson wrote: > How do I write a shell script that will change: [whatever] > to: [whatever] This one seems to come up every once in a while... Perl is probably easiest for in-place search-and-replace: perl -pi.old -e 's/10\.1\.1\.58/10\.0\.0\.1/g' fileone filetwo ... Remove the ".old" if you don't care to save the originals. The flags are explained fairly well in `perl -h`. It doesn't get much easier than that. :) The only downside is that it recreates every file (new inode (un-hardlinks) with updated [acm]time), even if no change was actually made. To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-isp" in the body of the message