Skip to content

Instantly share code, notes, and snippets.

@jarfil
Created July 24, 2014 20:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jarfil/e02f921bfdb06bbe3fa6 to your computer and use it in GitHub Desktop.
Save jarfil/e02f921bfdb06bbe3fa6 to your computer and use it in GitHub Desktop.
Free space from all devices
#!/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