Mac OS X – change a string in multiple files on the command line
Let’s say your team has been using the same license agreement in all source files for the entire year and during a code review someone happens to notice a misspelled word, or maybe the new year has arrived and you want to update the copyright notice. You can ask the new intern to open all 300 source files in your code repository and change each one, or even better, you can do it on the command line with a single line.
This command, typed into an OS X terminal will recursively change the misspelled word ‘auther’ to ‘author’ in every file with a “.as” extension in the current directory and below:
find . -name ‘*.as’ | xargs perl -pi -e ‘s/auther/author/g’