perl -ne 'print unless $seen{$_}++' data.txt Or, 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 '{ if (!seen[$0]++) print }'seen[$0]++' data.txt cat data.txt | awk '{ if (!seen[$0]++) print }'seen[$0]++'