1834417 Members
1676 Online
110067 Solutions
New Discussion

Adding up a bdf output

 
SOLVED
Go to solution
Donald C Nelson
Frequent Advisor

Adding up a bdf output

I have a bdf listing like:

Filesystem kbytes used avail %used Mounted on
/dev/vg00/lvol3 143360 60946 77357 44% /
/dev/vg00/lvol1 82480 31168 43064 42% /stand
/dev/vg00/lvol7 770048 681256 84561 89% /var
/dev/vg00/lvol6 770048 735307 32574 96% /usr
/dev/vg00/lvol4 204800 43809 150979 22% /tmp
/dev/vg00/lvol5 307200 241522 61909 80% /opt
/dev/vg01/data
102400 1133 94945 1% /data
/dev/vg02/data3
102400 1133 94945 1% /data3
/dev/vg03/emc 102400 1133 94945 1% /emc_mt

How can I add up of the sizes under Kbytes, Used, and avail.
3 REPLIES 3
RAC_1
Honored Contributor
Solution

Re: Adding up a bdf output

bdf|grep -v Filesystem|awk '{c+=$2} END {print c}'
And same for column 3 and four.
There is no substitute to HARDWORK
Biswajit Tripathy
Honored Contributor

Re: Adding up a bdf output

integer kbytes=0
integer used=0
integer avail=0
bdf | grep -v "^Filesystem" | \
awk '{print $2, $3, $4}' | while read -r k u a
do
kbytes=$kbytes+$k
used=$used+$u
avail=$avail+$a
done
echo KBytes = $kbytes
echo Used = $used
echo Avail = $avail

- Biswajit
:-)
Donald C Nelson
Frequent Advisor

Re: Adding up a bdf output

Thanks Biswajit and RAC. Both ideas helped me. I have submitted your points.