1
0
Fork 0
mirror of https://github.com/notwa/rc synced 2024-11-13 19:49:03 -08:00
rc/sh/dfu

22 lines
763 B
Bash
Executable file

#!/usr/bin/env sh
# compat: -ash +bash +dash +hush +ksh +mksh +oksh +osh +posh +yash +zsh YES_BB_AWK YES_OT_AWK
dfu() { ### @-
### pretty-print `df` in GiB.
###
### ```
### $ dfu
### Filesystem Used Max Left Misc
### /dev 0.00 0.46 0.46 0.00
### / 17.20 23.22 6.01 1.27
### ```
# FIXME: -x is not an option in busybox df.
[ $# -le 0 ] || { printf "%s\n" "$0: too many arguments" >&2; return 1; }
df -xtmpfs | awk '
NR==1{printf"%-20s %7s %7s %7s %7s\n","Filesystem","Used","Max","Left","Misc"}
NR>1{printf"%-20s %7.2f %7.2f %7.2f %7.2f\n",$6,$3/2^20,($3+$4)/2^20,($4)/2^20,($2-$4-$3)/2^20}'
}
[ -n "${preload+-}" ] || dfu "$@"