Grep and Count Duplicates

view story

http://www.unix.com – I have a delimited file (by |), and the second field is made out of Surnames. Is it possible to list the surnames together with their count of occurances. For example, image the first two lines are the following: Code: Joe | Doe | 30 Jane | Doe | 28 Peter | Smith | 25 John | Jones | 26 I would like an answer like the following Code: Doe 2 Smith 1 Jones 1 I managed to list the surnames by the following: Code: more FILENAME | awk -F"|" '{print $2}' Moderator's Comments: (HowTos)