![]() |
|
|
|
|
|||||||
| 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 |
| Array inside an array | manas_ranjan | UNIX for Advanced & Expert Users | 5 | 06-10-2008 11:25 AM |
| how to access values of awk/nawk variables outside the awk/nawk block? | saniya | Shell Programming and Scripting | 5 | 05-13-2008 04:37 AM |
| nawk/ksh help | DeltaX | Shell Programming and Scripting | 0 | 03-06-2008 12:54 PM |
| create array holding characters from sring then echo array. | rorey_breaker | Shell Programming and Scripting | 5 | 09-28-2007 05:42 AM |
| help with Awk or nawk | Gerry405 | UNIX for Dummies Questions & Answers | 2 | 11-28-2005 10:00 AM |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
nawk array help
This is a derivative of a question I asked earlier, but I can't figure out how to make all of the pieces work (mainly the array piece).
How do I get the following data set: aaa|bbb|ccc|123|ddd... abc|def|ghi|123|jkm... aaa|bbb|ccc|456|ddd... abc|def|ghi|456|jkm... aaa|bbb|ccc|789|ddd... abc|def|ghi|789|jkm... to look like: aaa|bbb|ccc|123|ddd... abc|def|ghi|123|jkm... Bascially I need to dedupe the file and I don't care which of the multiples I end up with. Also since the file layout can be multiple lenghts I was thinking about using $0 to just cover my bases. My name says it all. Help! |
| Forum Sponsor | ||
|
|
|
#2
|
|||
|
|||
|
Oh, I almost forgot, the only field that is used in matching is the first field - the "aaa" or "abc".
|
|
#3
|
||||
|
||||
|
Try...
Code:
awk -F '|' '!a[$1]++' file1 |
|
#4
|
|||
|
|||
|
It works great! Any chance you could explain what you did?
Thanks. |
|
#5
|
||||
|
||||
| Google The UNIX and Linux Forums |