[sed] How to use sed to remove all double quotes within a file

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?

This question is related to sed

The answer is


Try prepending the doublequote with a backslash in your expresssion:

sed 's/\"//g' [file name]

Are you sure you need to use sed? How about:

tr -d "\""

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

For replacing in place you can also do:

sed -i '' 's/\"//g' file.txt

or in Linux

sed -i 's/\"//g' file.txt

Try this:

sed -i -e 's/\"//g' file.txt