![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | 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 |
| using uniq and awk?? | amatuer_lee_3 | Shell Programming and Scripting | 13 | 05-17-2008 10:10 AM |
| How to uniq third field in a file | babycakes | UNIX for Dummies Questions & Answers | 1 | 01-31-2008 11:52 PM |
| help on UniQ | vishal_ranjan | HP-UX | 0 | 06-21-2007 07:33 AM |
| Moving Part of a field to another field using AWK | rjsha1 | Shell Programming and Scripting | 5 | 08-04-2006 02:39 AM |
| sort/uniq | jimmyflip | UNIX for Dummies Questions & Answers | 3 | 10-17-2002 02:09 AM |
|
|
LinkBack | Thread Tools | Display Modes |
|
|||
|
Uniq using only the first field
Hi all,
I have a file that contains a list of codes (shown below). I want to 'uniq' the file using only the first field. Anyone know an easy way of doing it? Cheers, Dave ##### Input File ##### 1xr1 1xws 1yxt 1yxu 1yxv 1yxx 2o3p 2o63 2o64 2o65 1xr1 1xws 1yxt 1yxv 1yxx 2o3p 2o63 2o64 2o65 1xr1 1yxt 1yxv 1yxx 2o3p 2o63 2o64 2o65 1y8y 2c68 2c69 2c6i 2c6k 2c6m 2c6o 1y8y 2c69 2c6i 2c6k 1zlt 2br1 2brb 2brn 2bro 2c3k 2cgu 2cgv 2cgx 1zlt 2br1 2brb 2brn 2bro 2cgu 2cgv 2cgx 1zlt 2br1 2brb 2brn 2bro 2cgv 2cgx 1zlt 2br1 2brb 2brn 2bro 2cgx 1zlt 2br1 2brb 2bro ##### Desired Output File ####### 1xr1 1xws 1yxt 1yxu 1yxv 1yxx 2o3p 2o63 2o64 2o65 1y8y 2c68 2c69 2c6i 2c6k 2c6m 2c6o 1zlt 2br1 2brb 2brn 2bro 2c3k 2cgu 2cgv 2cgx |
| Forum Sponsor | ||
|
|
|
||||
|
Quote:
Note that both awk solutions will work even if the file is not sorted (as far as the requirement is the uniqueness of the first field). P.S. Connot check right now if the w option is for the GNU version only. |
||||
| Google UNIX.COM |