Reputation: 1
I am new to shell scripting.I need to write a script to read each line from the file. Let's say each line has ID like A, B, C, D etc. But there can be duplicate IDs also. Two or more lines can have same ID. I need to find out the highest number for each ID. i.e if there are 3 IDs as "A". then I need to find out which is highest among those 3. and so on for ID "B", "C",,,and so on....
Thank you...
Upvotes: 0
Views: 254
Reputation: 161864
A 3
B 2
C 4
A 1
B 9
A 6
$ sort -k1,1 -k2,2nr data.txt | sort -u -k1,1
A 6
B 9
C 4
Upvotes: 1