Skip to content

Instantly share code, notes, and snippets.

@ChengLong
Last active January 2, 2016 08:49
Show Gist options
  • Save ChengLong/8279154 to your computer and use it in GitHub Desktop.
Save ChengLong/8279154 to your computer and use it in GitHub Desktop.
Find large files

The following command will list the top 10 biggest files, in descending order of file size, in the current directory.

sudo du -sm ./* | sort -nr | head -n 10

If the top result is a directory, you can cd into that directory and run the command again until you know what file is taking big space.

The above method is useful if you DO NOT know any characteristics of sought-after files. But if you DO know some characteristics like file name pattern or creation time, you are probably better off using find

find . -name "*.log" | xargs du -m | sort -nr | head -n 10

This command will

  • recursively find all files with pattern *.log in the current directory
  • sort them based on file size
  • return the top 10 biggest files
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment