The little things give you away... A collection of various small helper stuff
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

14 lines
431 B

  1. #!/bin/bash
  2. if [[ "$1" != "-c" ]]
  3. then
  4. # Without count (preserving order, printing the first appearance)
  5. # In this case, Perl is *much* faster than AWK.
  6. perl -ne 'print if ! $a{$_}++'
  7. #awk '!seen[$0]++'
  8. else
  9. # With count (order undefined)
  10. # Here, AWK is significantly faster.
  11. #perl -e 'while (<>) { $a{$_}++; } foreach $key (keys %a) { print "$a{$key} $key"; }'
  12. awk '{ tot[$0]++ } END { for (i in tot) print tot[i],i }'
  13. fi