Pages

Wednesday, August 19, 2020

SHELL: sed to search and replace the Variable

 Usually we search and replace a string on a file using SED editor. whereas in my scenario, i need to replace the string with the Variable on the Shell script. 

OLD_VAR = "blah blah"

NEW_VAR = "xyz"

   sed -i 's|'"$OLD_VAR"'|'$NEW_VAR'|g' temp-file.txt


No comments:

Post a Comment