Skip to main content
3 of 7
deleted 247 characters in body
Lesmana
  • 28.1k
  • 20
  • 85
  • 87

You can use the R programming language.

Suppose the data is in a file named datafile:

$ cat datafile 1 2 4 

Invoke non-interactive R using Rscript:

$ Rscript -e 'd<-scan("datafile", quiet=TRUE); \ cat(min(d), max(d), median(d), mean(d), sep="\n")' 1 4 2 2.333333 

You can write an R script file:

#! /usr/bin/env Rscript d<-scan("stdin", quiet=TRUE) cat(min(d), max(d), median(d), mean(d), sep="\n") 

Note the "stdin" which is a special filename to read from stdin.

And pipe the data to the R script:

$ cat datafile | ./mmmm.r 1 4 2 2.333333 

Also works for floating points:

$ cat datafile 1.1 2.2 4.4 $ cat datafile | ./mmmm.r 1.1 4.4 2.2 2.566667 

Read the fine R manuals at http://cran.r-project.org/manuals.html.

Unfortunately the full reference is only available in PDF. Another way to read the reference is by typing ?topicname in the prompt of an interactive R session.

Lesmana
  • 28.1k
  • 20
  • 85
  • 87