![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | 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 !! |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| stop unix find on a directory structure after finding 1st occurrence | jm0221 | Shell Programming and Scripting | 3 | 06-06-2008 08:19 PM |
| help with finding & replacing pattern in a file | dusoo | Shell Programming and Scripting | 0 | 05-23-2008 04:59 AM |
| replacing certain characters with new line? | Bashar | Shell Programming and Scripting | 4 | 05-13-2007 05:34 PM |
| finding & replacing blank rows/spaces in a file | Gerry405 | SUN Solaris | 2 | 07-21-2005 05:49 AM |
| shellscript for finding and replacing in DG-UNIX | Gerry405 | UNIX for Dummies Questions & Answers | 3 | 07-12-2005 09:12 AM |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
Finding nth occurrence in line and replacing it
Hi,
I have several files with data that have to be imported to a database. These files contain records with separator characters. Some records are corrupt (2 separators are missing) and I need to correct them prior to importing them into the db. Example: |field1|field2|field3|field4|field5|field6|field7|field8|field9|field10|field11|field12||| |field1|field2|field3|field4|field5|field6|field7|field8|field9|field10|field11|field12|field13|fiel d14|field15 |field1|field2|field3|field4|field5|field6|field7|field8|field9|field10|field11|field12|field13 The records 1 and 2 are correct. They consist of 15 optional fields separated by 15 | characters. Record 3 is corrupt since it's missing 2 separator characters ahead field13. It should look like: |field1|field2|field3|field4|field5|field6|field7|field8|field9|field10|field11|field12|||field13 How can I achieve this by using sed or awk or something else? Any help is greatly appreciated! TIA, Stephan. |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|