I've got a text file which has " marks where it there should be ' marks. I tried to do it with sed, but it won't allow me to escape the ' mark.
Here's what I tried to do:
sed 's/"/\\'/g' file.txt
How can this be done?
Thanks
I've got a text file which has " marks where it there should be ' marks. I tried to do it with sed, but it won't allow me to escape the ' mark.
Here's what I tried to do:
sed 's/"/\\'/g' file.txt
How can this be done?
Thanks
# echo 'foo"bar' | sed s/\"/\'/
foo'bar
The problem with what you tried, CraigMoore, is that you have two backslashes, \\. The first one escapes the second one, so you have a net of one backslash acting as a regular character, not escaping what follows it.
Ok. I thought it would be something simple. Thank you both for your help.