Published on

Find the Largest File in a Directory (recursive)

To find the largest file in a directory (recursively) in Linux, use:

find . -type f -exec du -h {} + | sort -rh | head -n 1

Explanation:

  • find . -type f: find all files starting from current directory (.)
  • -exec du -h {} +: get their sizes in human-readable form
  • sort -rh: sort by size (largest first)
  • head -n 1: show the largest one

If you only want files in the current directory (not recursive):

du -ah --max-depth=1 | sort -rh | head -n 1