Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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).
like image 214
qazwsx Avatar asked Jan 01 '12 23:01

qazwsx


People also ask

How do I list the top 10 files in a directory in Linux?

Steps to find Largest directories in Linuxdu command : Estimate file space usage. sort command : Sort lines of text files or given input data. head command : Output the first part of files i.e. to display first 10 largest file. find command : Search file.

How do I list top 10 files in Unix?

head command -10 OR -n 10 option : It shows the first 10 lines.


1 Answers

This prints the 10 largest files recursively from current directory.

find . -type f -printf "%s %p\n" | sort -nr | awk '{print $2}' | head -10
like image 81
ouah Avatar answered Oct 07 '22 18:10

ouah