command line utility to print statistics of numbers in linux

后端 未结 16 1629
無奈伤痛
無奈伤痛 2020-11-30 18:46

I often find myself with a file that has one number per line. I end up importing it in excel to view things like median, standard deviation and so forth.

Is there a

16条回答
  •  难免孤独
    2020-11-30 19:13

    Yet another tool which could be used for calculating statistics and view distribution in ASCII mode is ministat. It's a tool from FreeBSD, but it also packaged for popular Linux distribution like Debian/Ubuntu. Or you can simply download and build it from sources - it only requires a C compiler and the C standard library.

    Usage example:

    $ cat test.log 
    Handled 1000000 packets.Time elapsed: 7.575278
    Handled 1000000 packets.Time elapsed: 7.569267
    Handled 1000000 packets.Time elapsed: 7.540344
    Handled 1000000 packets.Time elapsed: 7.547680
    Handled 1000000 packets.Time elapsed: 7.692373
    Handled 1000000 packets.Time elapsed: 7.390200
    Handled 1000000 packets.Time elapsed: 7.391308
    Handled 1000000 packets.Time elapsed: 7.388075
    
    $ cat test.log| awk '{print $5}' | ministat -w 74
    x 
    +--------------------------------------------------------------------------+
    | x                                                                        |
    |xx                                   xx    x x                           x|
    |   |__________________________A_______M_________________|                 |
    +--------------------------------------------------------------------------+
        N           Min           Max        Median           Avg        Stddev
    x   8      7.388075      7.692373       7.54768     7.5118156    0.11126122
    

提交回复
热议问题