![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Replacing characters in csv file | finwhiz | UNIX for Dummies Questions & Answers | 1 | 03-31-2008 05:25 AM |
| replacing the characters in a file | trichyselva | UNIX for Dummies Questions & Answers | 2 | 01-03-2008 08:02 AM |
| replacing characters | palmer18 | UNIX for Dummies Questions & Answers | 3 | 08-20-2007 09:58 AM |
| Replacing characters in file with line break | johnemb | Shell Programming and Scripting | 10 | 04-26-2007 07:38 AM |
| replacing few characters in a file | purnakarthik | UNIX for Dummies Questions & Answers | 1 | 01-25-2007 05:17 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
Help Replacing Characters in Flat File
I was wondering if somebody could help me with something on UNIX. I have a file that looks like this -
"nelson,bill","bill","123 Main St","Mpls","MN",55444,8877,william I want to replace all comma with pipes (|), except if the comma is within double quotes. (The first field is an example of this.) I can't do do a sed looking for "," and replacing that with a pipe because not all fields have double quotes around them. Side note - I do not have access to Perl, so that's not an option. |
|
||||
|
Thanks...But what if
That worked for the sample that I gave you, but I thought of another scenario that I need to account for. What would happen if I added another comma to the end and then some more text? Sample -
"nelson,bill,jr","bill","123 Main St","Mpls","MN",55444,8877,william,bill I tried modifying your sed command and couldn't figure out how to make it work. |
|
|||||
|
Nelson,
Per my previous reply, your sample led me to believe the following: 1) Every non-numeric field would be surrounded by double quotes. except for "william". 2) Every numeric field would not be surrounded by double quotes. If the specs give reason to question, no final solution will be found. |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|