-   Linux - Newbie (
-   -   Removing the double quotes from the file globally (

abhimumtd 01-11-2012 07:25 AM

Removing the double quotes from the file globally
Hi Linux Gurus,

I am trying to remove all the double quotes from a file. Actually I have 48 files in all and some of them are pretty huge (as big as 12 gigs). So for example if one line in the file is like below -


Then I want it to become the following -


I want to be able to remove it globally.
I tried using "sed substitution" but I guess I am not using it correctly.

Any help is much appreicated.


theNbomr 01-11-2012 09:53 AM

Make a backup copy of your data. Use the backup to test.

sed s/\"//g  yourFile
When you've convinced yourself that this actually does what you want, add the -i option to the sed command, and it will edit 'in-place', rather than printing to standard output.

--- rod.

David the H. 01-11-2012 10:52 AM

I would instead suggest using the following variation, for readability reasons mostly:

sed 's/"//g'  infile
sed 's/["]//g'  infile        #regex variation

Single quotes escape double quotes, and vice versa. You can also enclose the character(s) to be deleted in [..] regex character class brackets, allowing you to delete multiple characters at once.

Or consider using tr instead:

tr -d '"' <infile >outfile
tr is more efficient at doing simple character substitutions/deletions than sed, but it only works through stdin, so you have to send the output to a new file.

All times are GMT -5. The time now is 10:18 AM.