Forrest logo
back to the echo tool

datamash:tldr:db2f2

datamash: Get the mean of a single column of numbers ignoring "Na" and "NaN" (literal) strings.
$ echo -e '1\n2\nNa\n3\nNaN' | datamash --narm mean 1
try on your machine

The given command performs a series of operations using the echo and datamash commands.

  1. echo -e '1\n2\nNa\n3\nNaN': This command uses echo to display the text "1\n2\nNa\n3\nNaN". The -e flag enables interpretation of escape sequences. In this case, \n represents a new line character, creating a line break after each number and the "Na" and "NaN" strings.

  2. |: This symbol is known as a pipe. It connects the output of the previous command (echo) to the input of the next command (datamash), allowing them to work together.

  3. datamash --narm mean 1: This command utilizes the datamash tool to calculate the mean of the numbers provided.

    • --narm tells datamash to ignore non-numeric values while calculating the mean.
    • mean 1 indicates that we want to compute the mean value for the first column of input, which in this case refers to the numbers "1", "2", "3".

Therefore, the entire command will output the mean value of the numbers: 2.

This explanation was created by an AI. In most cases those are correct. But please always be careful and never run a command you are not sure if it is safe.
back to the echo tool