Let us start off simple:
Imagine
you have a large file ( txt, php, html, anything ) and you want to
replace all the words "ugly" with "beautiful" because you just met your
old friend Sue again and she/he is coming over for a visit.

This is the command:

CODE

$
sed -i 's/ugly/beautiful/g'
/home/bruno/old-friends/sue.txt

Well, that command speaks for itself "sed" edits "-i in
place ( on the spot ) and replaces the word "ugly with "beautiful"
in the file "/home/bruno/old-friends/sue.txt"

Now, here comes the real magic:
Imagine
you have a whole lot of files in a directory ( all about Sue ) and you
want the same command to do all those files in one go because she/he is
standing right at the door . .
Remember the find command ? We will combine the two:

just replace the "*.php", "FINDSTRING" and "REPLACESTRING"
make it executable and you are set.

I
changed a www address in 183 .html files in one go with this little
script . . . but note that you have to use "escape-signs" ( \ ) if
there are slashes in the text you want to replace, so as an example:
's/www.search.yahoo.com\/images/www.google.com\/linux/g' to change
www.search.yahoo.com/images to www.google.com/linux