Skip to content

Instantly share code, notes, and snippets.

@aprell
Created June 15, 2012 15:40
Show Gist options
  • Save aprell/2937106 to your computer and use it in GitHub Desktop.
Save aprell/2937106 to your computer and use it in GitHub Desktop.
Simple script to calculate the average of a series of numbers
#!/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