Finding the BIG files with find

We often need to find the most voluminous files on our Ubuntu file systems for administrative clean-up or for what killed the cat - curiosity. The simplest and most direct command to do this is find with the following add-on helper functions:

find . -xdev -type f -size +100M -print | xargs ls -lh | sort -k5b,5 -h -r

Lets dissect this command a bit further.

find . - find files of given type at current location “.” and returns path included filename (e.g., /home/me/filename)

  • -xdev - do not descend directories on other file systems
  • -type c - file is of type “c”; f is a regular file
  • -size +n - file is equal to or greater than n; in this case >= 100 megabytes
  • -print - print the full file name on standard output, followed by a newline

xargs command - execute “command” once for each file found in list and send all results to stdout; think of this as a loop with the command inside

ls - list files

  • -lh - display “long” file information using human readable form (e.g., 100M)

sort - sort list using criteria

  • -k5b,5 - sort only on values in column 5 ignoring leading blanks (“b”)
  • -h - interpret value using human readable form of number (e.g., 100M)
  • -r - reverse the sort results

Update (22 May 2020): A friend pointed out a really nice command line application built around curses that provides "du"-style information called ncdu, which can be easily installed  using apt install ncdu.

Update (17 October 2024): A more helpful output when looking at raw bytes is the following:

find . -type f -size +100M -printf '%p\n' | xargs ls -l | sort -k 5 -nr