Hi all
is it possible to have a text pattern count statistic by using simple script instead count it one by one ?
apple
apple
boy
boy
boy
boy
cat
cat
cat
cat
cat
dog....
...
apple = 3
boy = 4
cat = 5
dog .....
Hi all
is it possible to have a text pattern count statistic by using simple script instead count it one by one ?
apple
apple
boy
boy
boy
boy
cat
cat
cat
cat
cat
dog....
...
apple = 3
boy = 4
cat = 5
dog .....
If there is only one word per line, then this should work:
awk '{a[$0]++}END{for (i in a){print i" = "a}}' file
Or shorter:
sort file | uniq -c