Reputation: 695
I have a file called file.txt. It has a number of double quotes throughout it. I want to remove all of them.
I have tried sed 's/"//g' file.txt
I have tried sed -s "s/^\(\(\"\(.*\)\"\)\|\('\(.*\)'\)\)\$/\\3\\5/g" file.txt
Neither have worked.
How can I just remove all of the double quotes in the file?
Upvotes: 63
Views: 165132
Reputation: 20242
For replacing in place you can also do:
sed -i '' 's/\"//g' file.txt
or in Linux
sed -i 's/\"//g' file.txt
Upvotes: 17
Reputation: 7337
Additional comment. Yes this works:
sed 's/\"//g' infile.txt > outfile.txt
(however with batch gnu sed, will just print to screen)
In batch scripting (GNU SED), this was needed:
sed 's/\x22//g' infile.txt > outfile.txt
Upvotes: 5
Reputation: 13244
You just need to escape the quote in your first example:
$ sed 's/\"//g' file.txt
Upvotes: 140
Reputation: 2450
Try prepending the doublequote with a backslash in your expresssion:
sed 's/\"//g' [file name]
Upvotes: 2