Recursively Find and Replace Strings in Files
Find, Linux, Sed
It can be useful to amend strings within project files - perhaps when spinning up a new project from a generated starting point.
I use this when setting the namespace of a new project.
Combine find and sed
Gnu find allows you to find files within a directory tree.
Sed is a unix utility that parses and transforms text, and is available for most operating systems.
Replace String in All Project Files
The command shown below is for Ubuntu.
find /path/to/my-project -type f -exec sed -i 's/OldString/NewString/g' {} \;find will execute sed substituting {} with the filename found - in this case, all files under /path/to/my-project.
The \; ending means that sed is passed one file at a time.
References
Exec: execute a commandsed, a stream editor. Parse & Transform text
comments powered by Disqus