Shell Tricks

For counting almost anything, use this idiom:

sort | uniq -c | sort -nr

How many users use each shell?

awk -F: '{print $7}' < /etc/passwd | sort | uniq -c | sort -nr

To count how many messages in a mailbox, and from whom they were sent:

formail -s head -l | tr '[A-Z]' '[a-z]' | awk '{print $2}' | sort | uniq    -c | sort -nr

To delete the first two lines in a file:

cat file | sed '1,2d'