![]() |
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 |
| 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 |
| how to delete duplicate rows in a file | vamshikrishnab | Shell Programming and Scripting | 5 | 06-18-2008 10:00 AM |
| Splitting file based on number of rows | wahi80 | Shell Programming and Scripting | 2 | 06-03-2008 09:38 PM |
| duplicate rows in a file | infyanurag | Shell Programming and Scripting | 3 | 05-22-2008 12:39 AM |
| Remove Duplicate lines from File | Nysif Steve | UNIX for Dummies Questions & Answers | 18 | 09-09-2007 08:57 AM |
| Remove Duplicate Lines in File | Teh Tiack Ein | Shell Programming and Scripting | 5 | 01-12-2006 08:30 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
Remove duplicate rows of a file based on a value of a column
Hi,
I am processing a file and would like to delete duplicate records as indicated by one of its column. e.g. COL1 COL2 COL3 A 1234 1234 B 3k32 2322 C Xk32 TTT A NEW XX22 B 3k32 2322 I want the file not to contain duplicate COL1. i.e. the file should only contain the ff: COL1 COL2 COL3 A 1234 1234 B 3k32 2322 C Xk32 TTT The records with duplicate COL1 were deleted. Anybody who has suggestions on how to do this? Thank you. |
|
||||
|
Thanks for the reply Jim. But when I tried the script, it returned "event not found error". any idea what's causing this error? also, i forgot to include in my sample, that the file i want to process is comma delimited. thank you.
COL1, COL2, COL3 A, 1234, 1234 B, 3k32, 2322 C, Xk32, TTT A, NEW, XX22 B, 3k32, 2322 |
|
||||
|
Thanks again Jim, but I still get the "arr[: event not found error".
I also noticed that when I recall the command (by pressing up arrow key), the part "![arr", is removed from the script. ie. the script becomesawk -F, '$1]++' oldfile > newfile im running on a solaris, and have also tried gawk and nawk, but the same error is being returned. thank you. |
|
||||
|
Thanks radolouv. But how do I use this?
$ cat uniq.awk !arr[$1]++ $ awk -f uniq.awk file what is uniq.awk file? |
| Sponsored Links | ||
|
|