Scripts for computing the average of a list of numbers in a data file
awk, bash, sed
Solution
Here is one method:
$ awk '{s+=$1}END{print "ave:",s/NR}' RS=" " file
ave: 54.646
Problem
The file `data.txt` contains the following: ``` 1.00 1.23 54.4 213.2 3.4 ``` The output of the scripts are supposed to be: ``` ave: 54.646 ``` Some simple scripts are preferred.