grep and replace string in many files

Carsten Aulbert carsten at welcomes-you.com
Fri Mar 9 11:17:09 UTC 2007


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 ;)

Carsten




More information about the ubuntu-users mailing list