On 2011-07-15 17:58, Matt wrote:
I have a file with lines like so but the number of them is in the
thousands instead of seven lines:
blue
red
red
red
orange
orange
green
I want it to count the occurances of each word it finds in the file.
So output on this small file would be:
blue (1)
red (3)
orange (2)
green (1)
The contents of the file are sorted already. Any ideas how to do this? Thanks.
With the numbers in front:
uniq -c file
I often use:
... |sort |uniq -c |sort -rn
to analyze some output.
--
Ruud
--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/