What's wrong with this Bourne shell script?
Andy Burgess
aab at silma.com
Sat Aug 4 05:32:31 AEST 1990
On SunOS 4.03c this script:
----------------------- cut here --------------
:
total=0
ls -ld * | while read line
do
set - `echo $line`
total=`expr $total + $4`
echo "Subtotal $total"
done
echo "Total $total"
----------------------- cut here --------------
The subtotal prints increasing numbers as you would expect.
At the end total prints as 0!
What gives?
While you're at it, is there a better way to get the total bytes
of the files in a directory?
Thanks
Andy Burgess
More information about the Comp.unix.questions
mailing list