fork download
  1. ! $2 in tomb {tomb[NR]=$2}
  2. /./ { myarray[$2]++ ; myarray2[$2, $1]++ }
  3. END { for ( key in myarray ) { print key ": " myarray[key] }
  4. print
  5. print "Duplicates: "
  6. for (key in myarray2) {
  7. split(key,sep,SUBSEP)
  8. if (myarray2[sep[1], sep[2]]>1)
  9. { print sep[1] ": " sep[2] " " myarray2[sep[1], sep[2]]
  10. }}}
Success #stdin #stdout 0s 4276KB
stdin
Tiger Animal
Tiger Animal
Parrot Bird
Lion Animal
Elephant Animal
Crow Bird
Horse Animal
Man Human
Dog Animal
stdout
Animal: 6
Human: 1
Bird: 2
Dog Animal
Duplicates: 
Animal: Tiger 2