recursive find and replace
Problem: I have a directory full of nested directories, which are themselves full of application code files. At runtime, I need to do a find-and-replace of some strings in these files.
Solution: use the bash powertools find
and sed
. Oh an we need a lil help from xargs
to read the stream of file names from find
stdout and pass them as arguments into sed
.
gnu linux syntax:
on mac, in-place sed
commands need an extra empty string before the substitute command (-i ''
). this goes back to the lineage difference where mac is bsd based and linux has the gnu sed. example: