Terminal Heroes – part 2 – sed all files
Posted by Ktoso on 30/08/2009 – 17:41
Did you ever have to substitute a single word with another one in lets say… 200 files? I just had to, since I used some old files from a client and wanted them to work in the new project – where some classes where named different because of Propel stuff. Here’s my solution:
find . -type f | while read a; do sed -i 's/Old/New/g' $a; done;
If put into words it reads like:
Find all files from here deep in all sub-directories and for each of them let sed substitute the word Old with New, please do this globaly in those files, and in place. Thanks sed, you saved my day.


Post a reply