snippetbashTip
datamash — Perform basic numeric, textual, and statistical operations on input textual data files. More informa
Viewed 0 times
textualcommandnumericdatamashandperformclibasic
linux
Problem
How to use the
datamash command: 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>.Solution
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 1Get the mean of a single column of float numbers (floats must use "," and not "."):
echo -e '1.0\n2.5\n3.1\n4.3\n5.6\n5.7' | tr '.' ',' | datamash mean 1Get the mean of a single column of numbers with a given decimal precision:
echo -e '1\n2\n3\n4\n5\n5' | datamash {{[-R|--round]}} {{number_of_decimals_wanted}} mean 1Get the mean of a single column of numbers ignoring "Na" and "NaN" (literal) strings:
echo -e '1\n2\nNa\n3\nNaN' | datamash --narm mean 1Code Snippets
Get max, min, mean, and median of a single column of numbers
seq 3 | datamash max 1 min 1 mean 1 median 1Get the mean of a single column of float numbers (floats must use "," and not ".")
echo -e '1.0\n2.5\n3.1\n4.3\n5.6\n5.7' | tr '.' ',' | datamash mean 1Get the mean of a single column of numbers with a given decimal precision
echo -e '1\n2\n3\n4\n5\n5' | datamash {{[-R|--round]}} {{number_of_decimals_wanted}} mean 1Get the mean of a single column of numbers ignoring "Na" and "NaN" (literal) strings
echo -e '1\n2\nNa\n3\nNaN' | datamash --narm mean 1Context
tldr-pages: linux/datamash
Revisions (0)
No revisions yet.