I'm wondering if it's possible to do the following just using unix command line utilities. Given a text file with duplicate lines, give a printout of all unique lines in the file and a count of how many copies there are of each.
Example file:
foo
bar
foo
baz
bar
Example output:
foo 2
bar 2
baz 1
It'd be trivial for me to write a script to accomplish this. I'm just wondering if there's a simple way to do it with sort, uniq, and awk or whatever.
Update: Solutions in the comments (thanks!).
Also, that should probably be "bar 2, foo 2, baz 1" for that last example, since "bar" comes before "foo" alphabetically. Though, ironically the order I gave is what you get with the straightforward sort -rn.
new⇒Johnny Walker Blue Label
Wow, thanks for the scotch review:D
Lagavulin and Laphroaig aresome of...
Keith: Aug 29, 3:35pm