"You could also use find and sed, but I find that this little line of perl works nicely.
perl -pi -w -e 's/search/replace/g;' *.php
- -e means execute the following line of code.
- -i means edit in-place
- -w write warnings
- -p loop over the input file, printing each line after the script is applied to it.
" (Extracted from http://www.liamdelahunty.com/tips/linux_search_and_replace_multiple_files.phpHow to do a search and replace over multiple files) suggests:
You could also use find and sed, but I find that this little line of perl works nicely.
perl -pi -w -e 's/search/replace/g;' *.php
- -e means execute the following line of code.
- -i means edit in-place
- -w write warnings
- -p loop over the input file, printing each line after the script is applied to it.
My best results come from using perl and grep (to ensure that file have the search expression )
perl -pi -w -e 's/search/replace/g;' $( grep -rl 'search' )