Help answer threads with 0 replies.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 01-11-2012, 07:25 AM   #1
LQ Newbie
Registered: Jan 2012
Posts: 1

Rep: Reputation: Disabled
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.

Old 01-11-2012, 09:53 AM   #2
LQ 5k Club
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,396
Blog Entries: 2

Rep: Reputation: 905Reputation: 905Reputation: 905Reputation: 905Reputation: 905Reputation: 905Reputation: 905Reputation: 905
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.
Old 01-11-2012, 10:52 AM   #3
David the H.
Bash Guru
Registered: Jun 2004
Location: Osaka, Japan
Distribution: Debian sid + kde 3.5 & 4.4
Posts: 6,823

Rep: Reputation: 1954Reputation: 1954Reputation: 1954Reputation: 1954Reputation: 1954Reputation: 1954Reputation: 1954Reputation: 1954Reputation: 1954Reputation: 1954Reputation: 1954
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.
1 members found this post helpful.



Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
escaping double quotes in a file koszta5 Linux - Newbie 3 12-12-2010 09:32 PM
Double Quotes Inside Double Quotes youarefunny Programming 6 06-09-2010 10:21 PM
Removing quotes from a CSV file with Perl Grafbak Programming 5 07-25-2006 03:23 AM
Using single quotes vs double quotes in PHP strings vharishankar Programming 6 07-11-2005 11:41 AM

All times are GMT -5. The time now is 03:17 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration