Disk usage script

Hello All,

With the help from Slidey earlier I have the following script

#!/bin/sh
if [ "$1" ]
then
VAR=`du -s $1|awk '{print $1}'`
echo "$1 - ${VAR}Mb Used";
else
tempfile="/tmp/available.$$"
trap "rm -f $tempfile" EXIT
cat << 'EOF' > $tempfile
{sum += $4 }
END { mb = sum /1024
gb = mb /1024
printf "%.of MB (%.2fGB) of available disk space\n" , mb, gb
}
EOF
df | awk -f $tempfile
fi
exit 0

However I would like it to also display what space is remaining.

I currently run this scrip as follows diskusage.sh /prod
/prod - 93104Mb Used

As you can see I get the disk space used but not what is free, any ideas how I get both results from one script.

Regards

 

 

 

 

Top