Sample Header Ad - 728x90

How to get only the unique results without having to sort data?

62 votes
5 answers
78525 views
$ cat data.txt aaaaaa aaaaaa cccccc aaaaaa aaaaaa bbbbbb $ cat data.txt | uniq aaaaaa cccccc aaaaaa bbbbbb $ cat data.txt | sort | uniq aaaaaa bbbbbb cccccc $ The result that I need is to **display all the lines from the original file removing all the duplicates (not just the consecutive ones), while maintaining the original order of statements in the file**. Here, in this example, the result that I actually was looking for was aaaaaa cccccc bbbbbb How can I perform this generalized uniq operation in general?
Asked by Lazer (36105 rep)
Apr 24, 2011, 08:23 PM
Last activity: Jan 28, 2024, 07:06 AM