Created
June 15, 2012 15:40
-
-
Save aprell/2937106 to your computer and use it in GitHub Desktop.
Simple script to calculate the average of a series of numbers
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
#!/bin/bash | |
# Calculate the average of a series of numbers | |
n=0 | |
while read number; do | |
echo $number | |
numbers+=$number"+" | |
n=$((n+1)) | |
done | |
numbers+="0" | |
echo "=========" | |
echo " Average " | |
echo "=========" | |
echo "scale=2; ($numbers)/$n" | bc |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment