![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| 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 !! |
|
|
||||
| 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 |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
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
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? |
| Forum Sponsor | ||
|
|
|
#2
|
||||
|
||||
|
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 |
|
#3
|
|||
|
|||
|
Thanks!!
Any inputs on replacing [","] with [,] and removing ["] at the start and end? |
|
#4
|
|||
|
|||
|
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 |
|||
| Google The UNIX and Linux Forums |