Hi,
I have a file with names:
Code:
John
Mary
Bob
Mary
Mary
Bob
and I am searching for an efficient way how to summarize every name ocurrence like this:
Code:
Mary - 3
Bob - 2
John - 1
I tried this:
1. sorted the file
2. removed duplicate lines using uniq and saved to a temp file
3. went through this file and used
Code:
grep -c $LINE file_with_names
to make the sum
It works but It seams to complicated for me. Is there a simplier solution? An one line command would be fine.