#!/bin/bash # Personalized 'df -h' with totals . /home/default #df -hP|awk '{ printf "%-25s %5s %5s %5s %5s %-20s \n", $6,$2,$3,$4,$5," "$1}' > $TMP df -hP > $TMP # cat $TMP # Uncomment previous and comment the next two # if df -h is not shown correctly cat $TMP|egrep -v '^/|@|/media/'|sort|awk '{ printf "%-25s %5s %5s %5s %5s %-20s \n", $6,$2,$3,$4,$5," "$1}' cat $TMP|egrep '^/'|egrep -v '/media/' |awk '{ printf "%-25s %5s %5s %5s %5s %-20s \n", $6,$2,$3,$4,$5," "$1}'|sort cat $TMP|egrep '/media/'|awk '{ printf "%-25s %5s %5s %5s %5s %-20s \n", $6,$2,$3,$4,$5," "$1}'|sort cat $TMP|egrep '@'|awk '{ printf "%-25s %5s %5s %5s %5s %-20s \n", $6,$2,$3,$4,$5," "$1}'|sort # The showing of the total information df > $TMP LINE # Get the sizes and percentage SIZE=`cat $TMP |egrep '^\/dev|@'|awk '{t2 = t2 + $2}END{print t2}'` USED=`cat $TMP |egrep '^\/dev|@'|awk '{t3 = t3 + $3}END{print t3}'` AVAI=`cat $TMP |egrep '^\/dev|@'|awk '{t4 = t4 + $4}END{print t4}'` PERC=$(echo -e "${USED}*100/${SIZE}\nquit"|bc) # Set in GB SIZE=$(echo -e "$SIZE/(1024*1024)\nquit"|bc) USED=$(echo -e "$USED/(1024*1024)\nquit"|bc) AVAI=$(echo -e "$AVAI/(1024*1024)\nquit"|bc) printf "%-25s %5s %5s %5s %5s %-20s \n" "All in GB" ${SIZE}G ${USED}G ${AVAI}G #Set in TB SIZE=$(echo -e "scale=2\n$SIZE/1024\nquit"|bc) USED=$(echo -e "scale=2\n$USED/1024\nquit"|bc) AVAI=$(echo -e "scale=2\n$AVAI/1024\nquit"|bc) printf "%-25s %5s %5s %5s %5s %17s \n" "All in TB" ${SIZE}T ${USED}T ${AVAI}T ${PERC}% @"`uname -mn`" LINE exit