Skip to content

Instantly share code, notes, and snippets.

@bucchere
Created January 4, 2013 19:56
Show Gist options
  • Save bucchere/4455408 to your computer and use it in GitHub Desktop.
Save bucchere/4455408 to your computer and use it in GitHub Desktop.
Human-readable disk usage, sorted in ascending order by size
du -sk * | sort -n | while read size fname; \
do for unit in k M G T P E Z Y;
do \
if [ $size -lt 1024 ]; \
then echo -e "${size}${unit}\t${fname}"; \
break; \
fi; \
size=$((size/1024)); \
done; \
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment