Created
October 27, 2014 13:31
-
-
Save Enucatl/cc1914214f5e0d5c338b to your computer and use it in GitHub Desktop.
calculate weighted average with first column = value, second column = weight with awk
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
#!/usr/bin/env bash | |
awk '{w = w + $2; e = e + $1 * $2;} END {print e/w}' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment