Skip to main content
use Gordon Davisson's improved awk script
Source Link
cjm
  • 27.7k
  • 12
  • 94
  • 87
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]++' 
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 }' data.txt cat data.txt | awk '{ if (!seen[$0]++) print }' 
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 '!seen[$0]++' data.txt cat data.txt | awk '!seen[$0]++' 
use camh's improved awk script
Source Link
cjm
  • 27.7k
  • 12
  • 94
  • 87
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] == 1!seen[$0]++) { print $0 } }' data.txt cat data.txt | awk '{ if (++seen[$0] == 1!seen[$0]++) { print $0 } }' 
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] == 1) { print $0 } }' data.txt cat data.txt | awk '{ if (++seen[$0] == 1) { print $0 } }' 
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 }' data.txt cat data.txt | awk '{ if (!seen[$0]++) print }' 
added awk version
Source Link
cjm
  • 27.7k
  • 12
  • 94
  • 87
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] == 1) { print $0 } }' data.txt cat data.txt | awk '{ if (++seen[$0] == 1) { print $0 } }' 
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{$_}++' 
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] == 1) { print $0 } }' data.txt cat data.txt | awk '{ if (++seen[$0] == 1) { print $0 } }' 
Source Link
cjm
  • 27.7k
  • 12
  • 94
  • 87
Loading