$ cat data.txt aaaaaaaaaaaaccccccaaaaaaaaaaaabbbbbb$ cat data.txt | uniqaaaaaaccccccaaaaaabbbbbb$ cat data.txt | sort | uniqaaaaaabbbbbbcccccc$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 wasaaaaaaccccccbbbbbbHow can I perform this generalized uniq operation in general?
How to get only the unique results without having to sort data?
text processing;uniq
perl -ne 'print unless $seen{$_}++' data.txtOr, if you must have a useless use of cat:cat data.txt | perl -ne 'print unless $seen{$_}++'Here's an awk translation, for systems that lack Perl:awk '!seen[$0]++' data.txtcat data.txt | awk '!seen[$0]++'