Use the find command to list all files matching the criteria and pipe through xargs to perl to find and replace the text with a regular expression (regexp) match. This example will replace oldtext with newtext in all .html files:
find . -name '*.html' | xargs perl -pi -e 's/oldtext/newtext/g'
As always, back up all files before doing this. In the regexp, remember to escape the necessary characters, e.g. slashes.
Taken from a post at http://www.linuxquestions.org/questions/showthread.php?t=203801.
