Search code examples
perlbashfilesize

How do I find the largest 10 files in a given directory?


How do I find the largest 10 files in a given directory, with Perl or Bash?

EDIT:

  • I need this to be recursive.
  • I only want to see large files, no large directories.
  • I need this to work on Mac OS X 10.6 ('s version of find).

Solution

  • This prints the 10 largest files recursively from current directory.

    find . -type f -printf "%s %p\n" | sort -nr | awk '{print $2}' | head -10