#!/bin/bash DF=/bin/df BLSI=${BLOCK_SIZE:-1024} SIZE=1k-blocks FLAG="" while (($#>0)) do case $1 in -g) BLSI=1073741824 shift ;; -m) BLSI=1048576 shift ;; -k) BLSI=1024 shift ;; -h|-H) unset BLSI HUMAN=$1 SIZE=Size shift ;; -G) BLSI=1000000000 shift ;; -M) BLSI=1000000 shift ;; -K) BLSI=1000 shift ;; -*) # Don't wrap for any other switch... BLSI=$BLOCK_SIZE $DF $@ exit ;; "") BLSI=${BLOCK_SIZE:-1024} shift ;; *) break ;; esac done unset BLOCK_SIZE case $BLSI in 1000) SIZE=1kB-blocks ;; 1024|1k) SIZE=1k-blocks ;; 1000000) SIZE=1MB-blocks ;; 1048576|1M|1024k) SIZE=1M-blocks ;; 1000000000) SIZE=1GB-blocks ;; 1073741824|1G|1024M|1048576k) SIZE=1G-blocks ;; "") true ;; *) SIZE=${BLSI}-blocks ;; esac printf "%-22s%10s%10s%10s %4s Mounted on\n" $(echo Filesystem "$SIZE" Used Available Use%) if [ -n "$HUMAN" ] then DISKFULL=$($DF -P "$HUMAN" $@ | sed -e 's^[ ]^~^g'|tail -n +2) for line in $DISKFULL do printf "%-32s%10s%10s%10s %4s %s\n" $(echo $line | sed -e 's^~^ ^g' -e 's^/dev/mapper/^/dev/^' -e 's^-^/^') done else export BLSI DISKFULL=$($DF -P $@ | sed -e 's^[ ]^~^g'|tail -n +2) for line in $DISKFULL do NR=0 for i in $(echo $line | sed -e 's^~^ ^g' -e 's^/dev/mapper/^/dev/^' -e 's^-^/^') do NR=$((NR+1)) POS[$NR]=$i done s=${POS[2]} u=${POS[3]} a=${POS[4]} printf "%-22s%10s%10s%10s %4s %s\n" ${POS[1]} $((s*1024/BLSI)) $((u*1024/BLSI)) $((a*1024/BLSI)) ${POS[5]} ${POS[6]} done fi