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

Re: [cobalt-users] Searching for a text string RaQ3.



Simulate Mode. This finds all htm(l) files containing the email address, and prints the name, line number, and line of the file:

find / -name '*.htm*' -exec grep -HnF 'user@xxxxxxxx'

Standard Mode. This finds the same files, and uses perl to change the email addresses, keeping a backup with a .bak extension:
find / -name '*.htm*' -exec grep -qF 'user@xxxxxxxx' -exec perl -p -i.bak -e 's/user\@home\.com/user\@attbi.com/'

If you replace "-exec" with "-ok" it will prompt you for each file first. I haven't tested it, so test it on a backed-up
subdirectory first.

Cheers,
Ben Liddicott
----- Original Message -----
From: "Steve Werby" <steve-lists@xxxxxxxxxxxx>

> You can use the "find" command to locate all of the files containing that
> text and additional commands to do the replacement if necessary, but it can
> get rather complex.  I suggest downloading rpl from laffeycomputer.com and
> using it instead.  It's simple to install following the included
> instructions.  It has a simulate mode that can be used to locate all files
> containing the matching string without doing a replacement and a standard
> mode which will do a replacement.
>
> http://downloads.laffeycomputer.com/current_builds/rpl-1.3.0b3.tar.gz