Skip to content

Instantly share code, notes, and snippets.

@stefanlasiewski
Created January 15, 2025 02:09
Show Gist options
  • Save stefanlasiewski/bf2e9c33460808ab3a05298d0ba9ad4e to your computer and use it in GitHub Desktop.
Save stefanlasiewski/bf2e9c33460808ab3a05298d0ba9ad4e to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
# Show the 20 largest files in a directory
# Borrowed from http://oreilly.com/pub/h/15
#set -x
set -euo pipefail
# du options
# -x File system mount points are not traversed.
# .[^.]* Include dotfiles, exclude '.' & '..'. Note that '--exclude' is not supported on a Mac
# $* Allow extra grep options, like '-n'
# Summarize disk space usage into a local file called .ducks
#nongnu# du -cks -x $* .[^.]* * | sort -n > .ducks ; tail .ducks
du -chs -x $* .[^.]* * | sort -h > .ducks ; tail .ducks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment