add up the numbers fast

From: Smith (smith_at_microsoft.com)
Date: 11/07/05


Date: Mon, 7 Nov 2005 22:42:18 +0800

Hi,
i have a file (name listfile.dat) that has a list of numbers, example

12
33
41
23
54
65
etc.. I have 8000 lines. I want to add up all the numbers.

I'm using a while loop,

while [ $loop_cnt -le 8000 ]
do
    line=`tail -$loop_cnt listfile.dat |head -1`
    numtoadd=`echo $line|cut -f1 -d" "`
    tot_count=`expr $tot_count + $numtoadd`
    loop_cnt=`expr $loop_cnt + 1`
done

It should works but it took very long to run. Is there a more efficient way
of doing it?

Regards