Created
July 24, 2014 20:56
-
-
Save jarfil/e02f921bfdb06bbe3fa6 to your computer and use it in GitHub Desktop.
Free space from all devices
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
fecho() { | |
local c | |
c=`perl -e "print ' ' x(15-${#1}) ; print $1"` | |
c=`echo "$c" | sed "s/\([^.]\{3\}\)/\1./g;s/\.\$//"` | |
echo -n "${c// ./ }" | |
} | |
tprint() { | |
echo " ttt.ggg.mmm.kkk.bbb" | |
echo "total: ""`fecho $1`" | |
echo "used: ""`fecho $2`" | |
echo "_free: ""`fecho $4`" | |
echo "free: ""`fecho $3`" | |
echo "lost: ""`fecho $5`" | |
} | |
z=`( IFS=$'\n' | |
for f in \`df -PB1 2> /dev/null | grep ^/dev/ | grep -v /tmp | grep -v cdrom | | |
sed "s/[^ ]* *\([^ ]*\) *\([^ ]*\) *\([^ ]*\).*/\1 \2 \3/"\` ; do | |
echo t=t+${f%% *} | |
f=${f#* } | |
echo u=u+${f%% *} | |
echo a=a+${f##* } | |
done | |
echo a2=t-u | |
echo l=a2-a | |
echo $'print t," ",u," ",a," ",a2," ",l\nquit' | |
) | bc -q` | |
tprint $z |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment