|
Try a bit of awk
burakkilic,
I normally use awk for this kind of problem - it works effectively
awk '{tot+=$1} END{print tot}' numbers.txt
Alternatively, change your script as shown:
#!/bin/sh
sum=0
for i in `cat numbers.txt |cut -f1`
do
sum=`expr $sum + $i` # Add back quotes around the expr
done
echo $sum
Steve
|