The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
Google UNIX.COM


UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
How to remove a character which is enclosed in Double quotes mohan_tuty UNIX for Advanced & Expert Users 3 06-16-2008 08:55 AM
Double quotes or single quotes when using ssh? password636 Shell Programming and Scripting 3 05-29-2008 05:52 PM
put double quotes for a column sumeet Shell Programming and Scripting 3 05-09-2007 04:20 PM
How do I insert double quotes dsean Shell Programming and Scripting 3 05-26-2006 10:28 AM
Double Quotes within a variable burton_1080 Shell Programming and Scripting 4 12-01-2005 10:44 AM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 05-30-2008
Registered User
 

Join Date: Feb 2007
Posts: 38
Remove double quotes

A Triva question.

What is the easy way to remove the double quotes in the file in the following format.

"asdfa","fdgh","qwer"

HTML Code:
tr -d '\"' <filename >newfilename
mv newfilename oldfilename
This need to be handled in a script. Any better way to do this. Will sed be more effecient?

One more question, If I come to know, " by itself a valid character in a field, I plan to remove "," and replace with , and in addition to that, first and last ".
May I know how to achieve this?
Reply With Quote
Forum Sponsor
  #2  
Old 05-30-2008
joeyg's Avatar
Moderator
 

Join Date: Dec 2007
Location: Home of world champion Boston Celtics
Posts: 983
Wink sed can accomodate this

sed s/\"//g data1.txt
note that the normal format is sed s/old/new/g
one needs to use a \ character before certain special characters to keep them from being interpreted.

An example follows:

Code:
> cat data1.txt
"asdfa","fdgh","qwer"

> sed s/\"//g data1.txt
asdfa,fdgh,qwer
Reply With Quote
  #3  
Old 05-30-2008
Registered User
 

Join Date: Feb 2007
Posts: 38
Thanks!!
Any inputs on replacing [","] with [,] and removing ["] at the start and end?
Reply With Quote
  #4  
Old 05-30-2008
Registered User
 

Join Date: Oct 2006
Location: Belgium
Posts: 171
Looks like you want to parse a CSV file. Try this:

Code:
$ str='"One","He said "I love *nix"","end"'
$ echo $str
> "One","He said "I love *nix"","end"

$ echo $str | sed 's/","/,/g; s/^"\|"$//g'
> One,He said "I love *nix",end
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 08:18 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0