/compute

Command-line Calculations

Primary LanguageShell

Compute is now GNU Datamash !

compute (now GNU Datamash is a command-line program to perform textual,numerical,statistical operation on text files.

Examples

What's the sum and mean of the values in field 1 ?

$ seq 10 | datamash sum 1 mean 1
55 5.5

Given a file with three columns (Name, College Major, Score), what is the average, grouped by college major?

$ cat scores.txt
John       Life-Sciences    91
Dilan      Health-Medicine  84
Nathaniel  Arts             88
Antonio    Engineering      56
Kerris     Business         82
...

Sort input and group by column 2, calculate average on column 3:

$ datamash --sort --group 2  mean 3 < scores.txt
Arts             68.9474
Business         87.3636
Health-Medicine  90.6154
Social-Sciences  60.2667
Life-Sciences    55.3333
Engineering      66.5385

For more details

License

Copyright (C) 2014 Assaf Gordon (assafgordon@gmail.com)

GPLv3 or later