Removing quotes in sed

I have a file and I want to remove quotes from the word " ` " through sed command but unable to remove
I am using below command

sed  s/"`XYZ`"/"ZXY"/g file1.txt > file2.txt

But this is not working. How can we remove "`" through sed command

sed  s/"\`XYZ\`"/"ZXY"/g file1.txt > file2.txt
1 Like

Can you post a sample of file1.txt? Backticks ( ` ) execute what is between them first. Since XYZ is not a command, you might have to escape the command, i.e. put a \ in front of each backtick. See below:

>cat file1.txt
"`XYZ`"

>sed s/"`XYZ`"/"XZY"/g file1.txt
-bash: XYZ: command not found
sed: -e expression #1, char 0: no previous regular expression

>sed s/"\`XYZ\`"/"ZXY"/g file1.txt
"ZXY"

Is that what you want it to do?

1 Like