expr inside a ksh script Solaris

Hi;
If I do something like this.
dftotalsize=0;export dftotalsize;df -k | grep \/db001 | awk '{print $4}' | while read theinput \
; do export $theinput; dftotalsize=`expr $dftotalsize + $theinput`; export dftotalsize; echo $dftotalsize; done ; echo `expr $dftotalsize \/ 1024 \/ 1024 "GB"

Is there a shorter way to do this because this will not fit on the one line.

Thanks.

df -k | awk '{sum+=$4}' END {print sum / 1024 /1024, "GB"}'

Hi,
well You don't have to have it on one line, do You? Whereever there is a ; just use ENTER instead to go to a new line.
And I don't think You need to export the variables. Instead of
dftotalsize=`expr $dftotalsize + $theinput`
You could use
dftotalsize=$((dftotalsize+theinput))

/Lakris

Absolutely awesome. Shoot, I thought i knew a bit about scripting and awk, and I was right, I know a BIT about it, but that is beautiful.

Thanks so much for that.

Thanks, but I think I wil go for the other option using awk. It also seems to give floating point numbers, whereas my way only gave the integers.