generating frequency table from file

后端 未结 6 2052
暗喜
暗喜 2021-01-31 07:51

Given an input file containing one single number per line, how could I get a count of how many times an item occurred in that file?

cat input.txt
1
2
1
3
1
0
         


        
6条回答
  •  梦毁少年i
    2021-01-31 08:45

    At least some of that can be done with

    sort output.txt | uniq -c
    

    But the order number count is reversed. This will fix that problem.

    sort test.dat | uniq -c | awk '{print $2, $1}'
    

提交回复
热议问题