![]() |
|
|
|
|
|||||||
| 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 |
| find and replace | javeed7 | Shell Programming and Scripting | 1 | 04-02-2008 06:00 AM |
| find and replace | mahabunta | UNIX for Dummies Questions & Answers | 7 | 09-21-2006 09:05 AM |
| find and replace | valhutch | UNIX for Dummies Questions & Answers | 4 | 07-29-2006 02:20 PM |
| find and replace | vikas_j@hotmail | UNIX for Dummies Questions & Answers | 3 | 02-25-2002 02:41 PM |
| Find & Replace | gagansharma | Shell Programming and Scripting | 3 | 11-27-2001 01:17 PM |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Find and replace
Hi,
I am trying to do this find and replace in unix and somehow its not working. Quote:
TR|20080417|23078 |000000104|20080418|0530|1040001 | I have the records coming in the above format. My requirement is if delimiter count is not 8 then put in the missing 2 delimiters. THen at the end of the file place CC. This one fails when at position 8 I get some data. ITs inserting TR|20080417|23078 |000000104|20080418|0530|1040001 | CC|| I dont want those 2 extra delimiters at the end. IT should be TR|20080417|23078 |000000104|20080418|0530|1040001 | CC. TR|20080325|22952 |000000040|20080327|0530||CC. Can anyone please help me out. Thanks Kiran |
| Forum Sponsor | ||
|
|
|
#2
|
||||
|
||||
|
Something like this?
(use nawk or /usr/xpg4/bin/awk on Solaris) Code:
awk 'NF=8{$NF=$NF"CC"}1' FS=\| OFS=\| file
|
|
#3
|
|||
|
|||
|
awesome!!
it worked THanks |
|||
| Google The UNIX and Linux Forums |