Computing.Net > Forums > Unix > Eliminating Duplicates from File

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Eliminating Duplicates from File

Reply to Message Icon

Name: maheshwar
Date: May 12, 2008 at 03:48:02 Pacific
OS: Unix
CPU/Ram: 512 MB
Comment:

We have a file like the following data. (emplid | exclude type | exclude reason)

01000000010|1|01
01000000010|1|03
01000000080|1|01
01000000080|1|02
01000000090|1|04
01000000100|1|01
01000000100|1|11

We want to sort the data and get one row for each emplid having lowest exclude reason through unix script. The out put should be like this.

01000000010|1|01
01000000080|1|01
01000000090|1|04
01000000100|1|01




Sponsored Link
Ads by Google

Response Number 1
Name: nails
Date: May 12, 2008 at 06:57:17 Pacific
Reply:

#!/bin/ksh

sort -u -t"|" -k 1,1 myfile.txt


0
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Unix Forum Home


Sponsored links

Ads by Google


Results for: Eliminating Duplicates from File

Finding unique records from file www.computing.net/answers/unix/finding-unique-records-from-file/4591.html

Process line from file -Cshell scr www.computing.net/answers/unix/process-line-from-file-cshell-scr/5072.html

print columns from files to a file www.computing.net/answers/unix/print-columns-from-files-to-a-file/7615.html