Below command can be used to find and replace all occurrences of a string in files inside a directory and sub directories.
Above command looks for string 1 in all files inside /tmp and replaces it with string2. You can change the directory name as needed from /tmp to any directory where you want to find and replace a string.
All Linux Operating Systems
https://stackoverflow.com/questions/6758963/find-and-replace-with-sed-in-directory-and-sub-directories
grep -rl 'string1' /tmp | xargs sed -i 's/string1/string2/g'
Above command looks for string 1 in all files inside /tmp and replaces it with string2. You can change the directory name as needed from /tmp to any directory where you want to find and replace a string.
Products to which Article Applies
All Linux Operating Systems
Additional References
https://stackoverflow.com/questions/6758963/find-and-replace-with-sed-in-directory-and-sub-directories
No comments:
Post a Comment