grep and replace string in many files

Matthew Flaschen matthew.flaschen at gatech.edu
Fri Mar 9 11:51:53 UTC 2007


Carsten Aulbert wrote:
> OOzy Pal wrote:
>> How can I replace each occurrences of 'images/' to 'img/' (quotes are
>> not included) from all my html files?
> 
> There are many ways to do it.
> 
> I would, for example, use something like that:
> 
> find . -name "*html" | xargs -n1 perl -i -ane 's/images/img/g; print;'
> 
> but your milage might vary and please test this first on a copy of the data.
> 
> HTH & don't blame me for my faults ;)

Perhaps:

find . -name "*html" | xargs -n1 perl -i -ane 's/images\//img\//g; print;'

would have been better.  The original would change *all* instances of
images, including outside html tags.

Matthew Flaschen




More information about the ubuntu-users mailing list