This page is dedicated to utility functions that I use often, but can never seem to remember them and typically end up googling for the answer.
Find-and-replace in lots of files
The following is based on this blog post.
To find-and-replace a string in lots of files use perl pie, e.g.
$ perl -p -i -e 's/search-this-string/replace-with-this-string/g' ./*.R
replace-with-this-string in all
Sometimes we want to perform this recursively, this can be done with the following line
$ find . -name '*.R' -print0 | xargs -0 perl -pi -e 's/oldstring/newstring/g'