Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 18 Dec 2000 03:55:13 -0800
From:      Steve Reid <sreid@sea-to-sky.net>
To:        Dave Wilson <davew@sai.co.za>
Cc:        freebsd-isp@FreeBSD.ORG
Subject:   Re: Off topic - shell skills
Message-ID:  <20001218035513.A33674@grok.bc.hsia.telus.net>
In-Reply-To: <NEBBJFIIGKGLPEBIJACLKEIJCJAA.davew@sai.co.za>; from Dave Wilson on Mon, Dec 18, 2000 at 11:33:10AM %2B0200
References:  <NEBBJFIIGKGLPEBIJACLKEIJCJAA.davew@sai.co.za>

next in thread | previous in thread | raw e-mail | index | archive | help
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




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