On Sat, 10 Mar 2001, Philips wrote:
> Chris Rodliffe wrote:
> >
> > I have a query - is there any cunning way (using grep or some similar
> > command) to replace a short text string in all the files in a directory
> > with another specified string? I know many things are possible with
> > Linux, just wondering if that is?
> >
>
> something like:
>
> find -type f -iname '*.c' -exec perl -i~ -p -e 's/suxx/rulezz/ig' {} \;
>
> will recursively replace word 'suxx' with 'rulezz' in all c files starting
>from current directory leaving a backup copy of each processed file in file with 'c~'
>extension.
>
> instead of perl can be used anything with enabled batch/macro processing - vim
>for example.
Many thanks! I _knew_ Linux would have a way to do it.
I do seem to have PERL on my system, too, so now seems to be
a good time to learn to use it.
Chris
"The three principal virtues of a programmer are Laziness,
Impatience and Hubris" - last line of _man perl_ ;-)
-
To unsubscribe from this list: send the line "unsubscribe linux-newbie" in
the body of a message to [EMAIL PROTECTED]
Please read the FAQ at http://www.linux-learn.org/faqs