Last active
November 25, 2022 01:43
-
-
Save darencard/785015b8e2cb3c5fbc7d to your computer and use it in GitHub Desktop.
Calculating the mean, minimum, and maximum of a column using Awk (vary $3 to reflect desired column of data)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cat <input.txt> | awk '{if(min==""){min=max=$3}; if($3>max) {max=$3}; if($3< min) {min=$3}; total+=$3; count+=1} END {print "mean =", total/count, "\nminimum =", min, "\nmaximum =", max}' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment