Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Possible Duplicate:
Unix command to list all directories larger than 10mb

How to find the largest file in a directory?

share|improve this question

migrated from Jan 4 '11 at 7:55

This question came from our site for professional and enthusiast programmers.

marked as duplicate by Sathya, BinaryMisfit Jan 4 '11 at 15:14

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

This is not a duplicate - the other wants large directories, this one wants large files. – AShelly Aug 22 '12 at 15:35

The best way is to use ls, sorted by size:

ls -S

To get the biggest one, use head:

ls -S | head -1
share|improve this answer

You can use the find command to do this work.

Let DIR is the directory in which you want to find the largest file, run the following command:

find DIR/ -type f -size +5000k

This will list the files whose size greater than 5MB. You can adjust this value (ie. option size) according to your need.

If you want to check the files under this DIR only, use the below one. You can adjust the maxdepth value to check in subfolder.

find ./ -maxdepth 1 -type f -size +5000k
share|improve this answer
this is nice. It would be even nicer if there was a way to show the size for each one found – AShelly Aug 22 '12 at 15:34

Assuming you're in the directory already:

du -a | sort -nr | head -1
share|improve this answer
Sizes for subdirectories are also calculated. Maybe you should mention that -- I'm not sure which approach the OP prefers. – Daniel Beck Jan 4 '11 at 9:11
Had it in there originally, figured it was logical to leave it in case one of the directories is large as well. – John T Jan 4 '11 at 9:14