LinuxQuestions.org
Go Job Hunting at the LQ Job Marketplace
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
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!

Notices

Reply
 
Search this Thread
Old 01-11-2012, 07:25 AM   #1
abhimumtd
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 -

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
 
Old 01-11-2012, 09:53 AM   #2
theNbomr
LQ 5k Club
 
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,395
Blog Entries: 2

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


Reply

Tags
sed


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 07:48 AM.

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