Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Tree: e1acb8f548
Fetching contributors…

Cannot retrieve contributors at this time

executable file 31 lines (26 sloc) 0.741 kB
#!/bin/sh
# reports disk usage for all specified files
# in order from least to greatest file size
#
# Usage: disk-usage [FILE]...
#
# if FILE not specified, then all files in
# the current working directory are used as
# the argument
#
#--
# Written in 2004 by Suraj N. Kurapati
if test $# -eq 0; then
set -- .* * # default argument is all files in pwd
shift 2 # remove . and ..
fi
usage_file=$(mktemp)
trap "rm -f $usage_file" EXIT
# preview output while capturing it
echo '---BEGIN-PREVIEW---' > /dev/tty
du -hs "${@}" 2>&1 | tee /dev/tty > "$usage_file"
echo '----END-PREVIEW----' > /dev/tty
# display units in increasing order
for unit in '\s' '[Kk]' '[Mm]' '[Gg]'; do
grep "^[0-9\.]\+$unit" "$usage_file" | sort -n
done
Jump to Line
Something went wrong with that request. Please try again.