I have a flat file where I have multiple occurrences of strings that contains single quote, e.g. hari's
and leader's
.
I want to replace all occurrences of the single quote with space, i.e.
- all occurences of
hari's
tohari s
- all occurences of
leader's
toleader s
I tried
sed -e 's/"'"/ /g' myfile.txt
and
sed -e 's/"'"/" "/g' myfile.txt
but they are not giving me the expected result.
Here is based on my own experience.
Please notice on how I use special char
'
vs"
aftersed
This won't do (no output)
but This would do
Try to keep sed commands simple as much as possible. Otherwise you'll get confused of what you'd written reading it later.
This will do what you want to
It will replace single quotes present anywhere in your file/text. Even if they are used for quoting they will be replaced with spaces. In that case(remove the quotes within a word not at word boundary) you can use the following:
HTH
I had to replace "0x" string with "32'h" and resolved with:
The -i should replace it in the file sed -i 's/“/"/g' filename.txt
if you want backups you can do sed -i.bak 's/“/"/g' filename.txt
Just go leave the single quote and put an escaped single quote:
also possible with a variable: