LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (http://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Removing the double quotes from the file globally (http://www.linuxquestions.org/questions/linux-newbie-8/removing-the-double-quotes-from-the-file-globally-923238/)

abhimumtd 01-11-2012 08: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 -

1,"approval","Approval","Approval"

Then I want it to become the following -

1,approval,Approval,Approval

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.

TIA
Abhi

theNbomr 01-11-2012 10:53 AM

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

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 11:52 AM

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

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:
Code:

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 11:58 PM.