Replacing text within a bunch of files

Chris redhat-list at dotcomdesigners.com
Sat Apr 10 18:55:24 UTC 2004


I'm having a bit of a problem trying to figure out how to properly use 'sed' to
do a global search and replace on a character string within ALL files in a
directory and all its subdirectories.  The one-file-at-a-time method works fine,
but obviously this needs to be looped to traverse all files and all
subdirectories...

This is what I've tried:

sed -e 's/old_string/new_string/g'  foo1.txt > foo2.txt

and it works fine.  How can I loop it automatically through all
file/subdirectories, though?

Thanks!

Adam





More information about the redhat-list mailing list