binsh

useful shell scripts
Log | Files | Refs | LICENSE

dfs (478B)


      1 #!/bin/sh 
      2 # prints df(1) then the totals of each statistic
      3 # TODO: align the numbers for totals to match df(1) output
      4 set -e
      5 df -h | grep ^[a-zA-Z/]
      6 df -k | awk '
      7 	function human(kb) { order=1; while (kb >= 1000) { kb /= 1024; order++ }; return sprintf("%.1f%c", kb, substr("KMGTPE", order, 1)) }
      8 	NR > 1 && /^\/dev/ { devs++; size += $2; used += $3; avail += $4; cap += $5 }
      9 	END {printf "Total:\t\t\t\t%s\t%s\t%s\t%d%%\n", human(size), human(used), human(avail), cap/devs }'