Question : doing math in a bash script.

I'm grepping a file and getting a list of about a thousand numbers that I need to average and total.. The numbers are not big. The numbers I'm trying to add and average will be between 0 and 10000. What's the best way to average and add these numbers in a bash script?  I know I can send the list to a new file and read though it and do the math but I was hoping there might be a way to avoid creating a temp file. Any ideas?

Answer : doing math in a bash script.

Something like this may help:
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
#!/bin/bash

SUM=0
ELEMENTS=0
AVG=0

cat myFile | while read line; do
if [ -n "$line" ]; then
let ELEMENTS++;
let SUM=$SUM + $line # let SUM+=$line?? not sure
fi
done

let AVG=$SUM/$ELEMENTS
echo $AVG
Random Solutions  
 
programming4us programming4us