Skip to content

Instantly share code, notes, and snippets.

@boywijnmaalen
Last active April 9, 2018 05:05
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 boywijnmaalen/14b959f476d3ab06485a5e3c94b9271f to your computer and use it in GitHub Desktop.
Save boywijnmaalen/14b959f476d3ab06485a5e3c94b9271f to your computer and use it in GitHub Desktop.
order directory content by size
# MAC
$ du -sh /directory/to/search/*/ | sort -n -r
# UNIX
$ du -hc --max-depth=1 . | sort -n -r
# du:
# -s, --summarize Display only a total for each argument.
# -h, --human-readable Append a size letter such as `M' for megabytes to each size.
# Powers of 1024 are used, not 1000; `M' stands for 1,048,576 bytes
# Use the `-H' or `--si' option if you prefer powers of 1000.
# -c, --total
# Print a grand total of all arguments after all arguments have been
# processed. This can be used to find out the total disk usage of a
# given set of files or directories.
#
# sort:
# -n, --numeric-sort compare according to string numerical value
# -r, --reverse reverse the result of comparisons
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment