Search and Replace string with SED | Mahdi Hazaveh
sed (Stream Editor) is a tiny cool tool shipped in most linux distros. most of the times I use sed to lookup for pieces of strings in my projects and replace them in cases that I'm moving them from one environment to another. to run sed for search and replace purpose on a single file you can do: [crayon-5c9549f320730938723836/] The above command will look up the file.txt in and search all occurances of 'oldstring' to 'newstring'. To do this in a recursive mode and all the files in a directory you can mix it up with find command. [crayon-5c9549f32073a887563356/] note I've passed "." as the target directory to find, means I should be in the directory that I wish to run the search in. you can also replace "." with the path of the directory you wish to do your search and replace in.
Post to Tumblr