How to mass Search & Replace in text files.

Jamon Camisso jamon.camisso-H217xnMUJC0sA/PxXw9srA at public.gmane.org
Fri May 1 15:12:32 UTC 2009


Lance F. Squire wrote:
> Alex Beamish wrote:
>> The classic tool for doing this is sed .. but you could also use perl
>> -ie 's/Bad JS//' *.html
>>
> 
> So....
> 
> sed 's/Bad JS//' *html
> 
> Would that search recursively?

I prefer using a shell, so I'd use something like this:

for i in `grep "Bad JS" *.html -R -l`; do echo "Bad JS found in $i"; sed 
-i 's/Bad JS//' $i; done

To others on the list, what's the better way using grep/find? Seems like 
using grep recursively in this case accomplishes the same thing as 
grepping through find results.

Jamon
--
The Toronto Linux Users Group.      Meetings: http://gtalug.org/
TLUG requests: Linux topics, No HTML, wrap text below 80 columns
How to UNSUBSCRIBE: http://gtalug.org/wiki/Mailing_lists





More information about the Legacy mailing list