I am having many text file with different directories. I need to search one specific string and I need to replace the string with the specific value as $test
.
I need to search the all files in all directories, for this.
Example:
In one file there is a string as abcd
, I need to replace the string abcd
as $test
.
I have a script that is searching the string in all files and replacing the string. But I can't able to replace the string with $
symbol.
Below script is working without $
.
command="find \`pwd\` -name \"*\" -type f -exec grep -l \"abcd\" {} \\; 2>/dev/null | xargs perl -pi.bak1 -w -e 's/abcd/test/g;'"
Below script is not working with $
symbol.
command="find \`pwd\` -name \"*\" -type f -exec grep -l \"abcd\" {} \\; 2>/dev/null | xargs perl -pi.bak1 -w -e 's/abcd/\$test/g;'"
How to replace the string abcd
to $test
.
\\\$
. You do want to replace with the actual string$AH
, right? Not with the value of the shell variable$AH
? – Kusalananda May 14 '18 at 19:51