I have a varibale TMP have string and I am using that string to be replaced using sed command to null.
TMP variable has string like this "dec$|fgh$|yxz$" and I am using this command
example.txt file contains string like this hello dec$|fgh$|yxz$
sed -i "s/hello \"$TMP\"//g" /example.txt
But this command is not replacing?
hello "dec$|fgh$|yxz$"
but you say your input hashello dec$|fgh$|yxz$
instead. Get the text you want to remove into a$lhs
variable (maybelhs="hello $TMP"
) and use the method given in the dup Q&A to get your$escaped_lhs
. – Stéphane Chazelas Jun 22 '22 at 16:31