Skip to content

Instantly share code, notes, and snippets.

@yumyo
Created November 29, 2012 18:24
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 yumyo/4170929 to your computer and use it in GitHub Desktop.
Save yumyo/4170929 to your computer and use it in GitHub Desktop.
Unix Directory search
To find the largest 10 files (linux/bash):
find . -type f -print0 | xargs -0 du -s | sort -n | tail -10 | cut -f2 | xargs -I{} du -sh {}
To find the largest 10 directories:
find . -type d -print0 | xargs -0 du -s | sort -n | tail -10 | cut -f2 | xargs -I{} du -sh {}
Alternatively or a quick view:
du | sort -n
lists all directories with the largest last.
du --max-depth=1 * | sort -n
or, again, avoiding the redundant * :
du --max-depth=1 | sort -n
lists all the directories in the current directory with the largest last.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment