Reputation: 3100
I have string: this is a [\"sample\"] sample\'s.
What would be the correct way to remove backslashes from the double quote, preserving the double quote.
Expected output: this is a ["sample"] sample\'s.
I've tested: sed -i 's/\\\"//g' file.txt
which is removing the "
Upvotes: 0
Views: 727
Reputation: 6134
Your command is almost correct. You just forgot to substitute with a double quote:
sed -i 's/\\"/"/g' file.txt
sed
's s
command substitutes the first part (between /
here) with the second part. The g
flag repeats the operation throughout the line. Your mistake was that the second part was empty, thus effectively deleting the whole \"
string.
BTW, escaping the double quote is not necessary since your sed
command is inside single quotes.
Upvotes: 4