Use the following at your own risk. Save off your files within your directory somewhere first before running the following command. I’m posting these notes so I can refer back to them.
If you want to search and replace a word in all files within a specified directory in Unix, do the following:
For example, here I wanted to do a global search and replace of all files within the current directory to ‘2010’ from ‘2008’. My main goal was to update all Copyright dates specified in my html and php files.
find . -type f | xargs perl -pi -e 's/2008/2010/g'
Leave a Reply