#!/usr/bin/awk -f # Data averaged is the first column of the numbers provided # Gives average and error for uncorrelated data. # Careful: Empty lines will give wrong result! How to go around that? { av += $1; # the sum of data er += $1*$1; # the sum of squares of data } END{ #we assume NR is the number of data (wrong if empty lines) av /= NR; er /= NR; # formula for error of uncorrelated measurements er = sqrt( (er - av*av)/(NR-1) ); print av, "+/-", er; }