Hi All,
I have a script which throws the output if condition matches. I run the cmd :
# ldf
Filesystem kbytes used avail capacity Mounted on
/dev/dsk/c1t0d0s0 1984564 1375019 550009 72% /
/dev/dsk/c1t0d0s3 5040814 2628410 2361996 53% /usr
/dev/dsk/c1t0d0s5 1984564 815790 1109238 43% /var
/dev/dsk/c1t0d0s6 12096820 8579296 3396556 72% /home1
/dev/dsk/c1t0d0s7 8265819 6076332 2106829 75% /home2
/dev/dsk/c1t0d0s4 5040814 3965027 1025379 80% /opt
Now I want to get the output only of those partitions whose used space is more than 70%. The below script works:
---------------------------------------------------------------------
#!/bin/bash
rm -rf /deepak/out.txt
var=1
max=`ldf | awk 'NR>1' | awk '{print $5}' | cut -b1-2 | wc -l`
while [ $var -le $max ]
do
val=`ldf | awk 'NR>1' | awk '{print $5}' | cut -b1-2 | sed -n "${var}p"`
if [ $val -ge 70 ]
then
dir=`ldf | awk 'NR>1' | awk '{print $6}' | sed -n "${var}p"`
echo " $dir = $val%" >> /deepak/out.txt
fi
var=`expr $var + 1 `
done
-----------------------------------------------------------------------
I know, this task can be done by much simple way. Can anyone suggest?
Thanks,
Deepak Tiwari