Search and Replace text in all files in a folder and its subfolders
by Mahdi Sajjadpour

To replace all occurances of a string:
find /your/home/dir -name "*.txt" | xargs perl -pi -e 's/stringtoreplace/replacementstring/g'

To replace the first occurance:
find /your/home/dir -name "*.txt" | xargs perl -pi -e 's/stringtoreplace/replacementstring/'

To replace all files in a folder:
for arg in `ls -C1`; do perl -pi -e 's/stringtoreplace/replacementstring/g'; done;

you can do more cool tricks using the for shell command as demonstrated above. you can add more specific searches. However, you might be better off just writing a shell script. Here is an example of the first find:
for arg in `find /your/home/dir -name "*.txt"` ; do perl -pi -e 's/string/replacement/g' $arg; done;

Copyright by techTips