The example input and output was updated; the examples in the first section use the original example input to show detail examples on variants:
Original input in Original_File:
User1 US
User1 NG
User2 US
User3 US
User4 US
User5 US
You can skip the userN part for uniq with the option -f to skip leading fields - separated by space:
$ sort -t" " -k1,1 Original_File | uniq -f 1
User1 NG
User1 US
For the same order as in the example output, you can reverse the sort - this will change the "label" values of the unique lines:
$ sort -r -t" " -k1,1 Original_File | uniq -f 1
User5 US
User1 NG
Note the User5 in the first result line. If that's not acceptable, just sort again:
$ sort -t" " -k1,1 Original_File | uniq -f 1 | sort -t" " -k1,1 -r
User1 US
User1 NG
If the UserN part is not separated by space, but has a fixed length, you can skip it for uniq with the option -s:
$ sort -t" " -k1,1 Original_File | uniq -s 6
User1 NG
User1 US
With the updated example input, this is the command for creating the required sort order:
$ sort -t" " -k1,1 Original_File | uniq -f 1 | sort -t" " -k1,1 -k2,2r
User1 US
User1 NG
User4 US
User4 EN
it sorts the second field to reverse order.
User3 US, and being asked by him, it is not duplicated in any way.How to find the difference between...is totally different toHow to find duplicates from a file. – Tim Aug 27 '14 at 16:30User4 USandUser4 ENimportant? CouldUser4 USbe the last line? – Volker Siegel Aug 27 '14 at 16:46