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

Re: Howto search and replace...



-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi,

Jaume Teixi <teixi@6tems.com> writes:

> Howto search and replace for a pattern over all system files ?
> 
> It's faster with vi, ed ?

sed.  And a bit of shell script.  For instance (off the top of my head,
so no guarantees):

for i in $file_list; do \
        mv $i $i~; \
        sed -e "s/old/new/g" < $i~ > $i; \
done

And that'll even leave the old version of the file with a ~ extension.
$file_list can be generated with something along the lines of:

$file_list=`find /etc -type f`

That'd give you a list of all the files in /etc.

Let me guess - you're trying to change you're domain name? :)

- -- 
Graeme.
graeme+sig@mathie.cx

"Life's not fair," I reply. "But the root password helps." - BOFH
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.1 (GNU/Linux)
Comment: Processed by Mailcrypt 3.5.5 and Gnu Privacy Guard <http://www.gnupg.org/>

iD8DBQE5GUwiPjGH3lNt65URAoPDAJ94q6ucgtFutQoy9IS9aqNOHxPDYACgp0yx
YO7Owhe+nLJB+EHTvejD8WU=
=3HEh
-----END PGP SIGNATURE-----



Reply to: