Hi guys,
I have yet another awk question. I have a list of items:
Lemon Juice
Orange
Lemon Juice
Apple
Lemon
I need to be able to count, through an awk script the number of times a 'line' (think Lemon Juice instead of only Lemon) repeats itself in the list of items. I got as far as counting the number of times a word repeat itself with the following (thanks to Google):
{for (i=1;i<=NF;i++)
count[$i]++
}
END {
for (i in count)
print count, i
}
But that wil spit out every occurance of the words in the list:
3 Lemon
2 Juice
1 Orange
1 Apple
Whereas what I would need is:
1 Lemon
2 Lemon Juice
1 Orange
1 Apple
Could anybody pinpoint where and how I could change the script to count lines of words instead of individual words? Thank you!