How to find top K largest files in a directory on Linux?

I have many files in a directory on Linux. How to find top K largest files in a directory?

For example, find top 10 (K=10) large files in the current directory:

du -h --max-depth 1 * | sort -rh | head -n 10
Answered by Eric Z Ma.

Eric Z Ma

Eric is a father and systems guy. Eric is interested in building high-performance and scalable distributed systems and related technologies. The views or opinions expressed here are solely Eric's own and do not necessarily represent those of any third parties.

Leave a Reply

Your email address will not be published. Required fields are marked *