[CentOS] Scripting help please....
John Doe
jdmls at yahoo.com
Thu Oct 29 10:26:08 UTC 2009
From: John Doe <jdmls at yahoo.com>
> A quick and dirty example (only prints the extra duplicate lines; not the
> original duplicate):
> awk -F: ' { v[$3]=v[$3]+1; if (v[$3]>1) print $0; } ' datafile
Here's the version will the 1st duplicate included:
awk -F: ' { v[$3]=v[$3]+1; if (v[$3] == 1) { f[$3]=$0; } else { if (v[$3] == 2) print f[$3]; print $0; } } ' datafile
More information about the CentOS
mailing list