Howto search and replace...

2000-05-10 Thread Jaume Teixi
Howto search and replace for a pattern over all system files ?

It's faster with vi, ed ?



Re: Howto search and replace...

2000-05-10 Thread Oswald Buddenhagen
 Howto search and replace for a pattern over all system files ?
 
try a perl-expression. 
find / '!' -type d -exec perl -e s/foo/bar/baz '{}' ';'
this is definitely not ready-to-run, but it's a good point to start 
from. look at the perl man page.


-- 
Hi! I'm a .signature virus! Copy me into your ~/.signature, please!
--
Linux - the last service pack you'll ever need.



Re: Howto search and replace...

2000-05-10 Thread Graeme Mathieson
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Hi,

Jaume Teixi [EMAIL PROTECTED] 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.
[EMAIL PROTECTED]

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-



Re: Howto search and replace...

2000-05-10 Thread w trillich
perl is designed for this kind of thing.

use it carefully, though--AFTER you back everything up!

#!/usr/bin/perl
use File::Find;

see 'man File::Find' (or perldoc 'File::Find') for the
full poop.

-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
Their is five errers in this sentance.