Today I Learned

A Hashrocket project

Ready to join Hashrocket? Find Openings here and apply today.

Counting occurrences in shell

Today I learned that uniq has an -c option that counts the number of times the line occurred and prepends for each uniq result. That’s very handy tool:

$ echo "foo\nfoo\nbar\nfoo" | sort | uniq -c
   1 bar
   3 foo