mirror of
https://github.com/ivuorinen/cheatsheet-tldr.git
synced 2026-01-26 11:33:59 +00:00
40 lines
870 B
Plaintext
40 lines
870 B
Plaintext
---
|
|
syntax: markdown
|
|
tags: [tldr, linux]
|
|
source: https://github.com/tldr-pages/tldr.git
|
|
---
|
|
# datamash
|
|
|
|
> Perform basic numeric, textual, and statistical operations on input textual data files.
|
|
> More information: <https://www.gnu.org/software/datamash/manual/datamash.html#Invoking-datamash>.
|
|
|
|
- Get max, min, mean, and median of a single column of numbers:
|
|
|
|
`seq 3 | datamash max 1 min 1 mean 1 median 1`
|
|
|
|
- Get the mean of a single column of float numbers (floats must use "," and not "."):
|
|
|
|
`echo -e '1.0
|
|
2.5
|
|
3.1
|
|
4.3
|
|
5.6
|
|
5.7' | tr '.' ',' | datamash mean 1`
|
|
|
|
- Get the mean of a single column of numbers with a given decimal precision:
|
|
|
|
`echo -e '1
|
|
2
|
|
3
|
|
4
|
|
5
|
|
5' | datamash {{[-R|--round]}} {{number_of_decimals_wanted}} mean 1`
|
|
|
|
- Get the mean of a single column of numbers ignoring "Na" and "NaN" (literal) strings:
|
|
|
|
`echo -e '1
|
|
2
|
|
Na
|
|
3
|
|
NaN' | datamash --narm mean 1`
|