Server Fault is a question and answer site for system and network administrators. 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

What command should I use to find the file with the maximum size in a certain folder containing sub-directories which are several level deep. (in windows / linux)

share|improve this question
up vote 3 down vote accepted

You can use the following command under Linux:

find /path/to/folder -printf "%p:%k\n" | sort -k 2 -rn -t : | head -n 1 | cut -f 1 -d :

If you want to get size also (in kilobytes), you can remove the last cut.

share|improve this answer
$ find /path/to/folder -type f -printf "%s %p\n" | sort -n | tail -1 – quanta Dec 8 '11 at 16:10
find /dirname -type f -ls | sort -nr -k 7,7 | head -n 1

will list all files under dirname and sort them in reverse order (largest first) with a numerical sort for the 7th field.

BTW: This is on Linux/Unix.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.