# This is a very useful command line program that can be used to do a recursive word search
# and replace on a directory.
# Perl needs to be installed on the server.
##############################

find . -type f -print | xargs egrep -il 'oldword'| perl -pi.bak -e "BEGIN {push @ARGV,; chomp @ARGV} s/oldword/newword/g"


A brief explanation of the three parts.
1. find . -type f -print:  the find program searches recursively for files and outputs their name which is piped to:
2. xargs egrep -il 'oldword': xargs is necessary to call egrep for each file piped from 'find'. Also grep can be used instead
of egrep. The -i option ignores case distinctions and the -l option prints the file name whenever there is a match.
3. perl -pi.bak -e "BEGIN {push @ARGV,; chomp @ARGV} s#newword#oldword#g": The options -pi allow the editing of all file names
received.The ".bak (notice the period before bak) means any file created will have the original file copied with a ".bak" extension.
If no extension is given then the file is edited in place without a copy of the original being created. The substitution is done by
"s/oldword/newword/g". Like sed you can use other symbols as delimiters such as "#" or "?". This is convenient when editing a
file path listed inside several files. ex. /usr/local/example.pl