Snippets are tiny notes I've collected for easy reference.
Find large files on Linux.
UPDATE: Reader Luc Pionchon points out that sort
often supports a -h
parameter that sorts by "human" numbers, hence:
$ du -h * | sort -h | tail
is probably a better alternative than any of the following (for the systems that support it).
du -h * | grep "^[0-9.]*M" | sort -n
This finds files at least 1 MB in size and then sorts them by size. Change M
to G
for files at least 1 GB in size.
(Caveat: files 1 GB or larger will be missed by the MB version. You can use:
du -h * | egrep "^[0-9.]*(M|G)"
to get both, but then the sort -n
doesn't work quite the way we'd like.)
Of course, you could use du
without the -h
to get file sizes by the default block size rather than the human-readable 12.4M or 16K, etc.
Snippets are tiny notes I've collected for easy reference.