Ubuntu – How to display disk usage by file type

command linedisk-usage

Basically I'm wondering where all my disk space is being eaten up on my drive and I would like to be able to analyze by file type

For example, I'd like to use the Terminal to see how much space is being used by the .psd files on my drive.

Is there a way to do such a thing?

Best Answer

Try this:

find . -iname '*.psd' -print0 | du -ch --files0-from=-
  • find . -iname '*.psd' finds all files that end with an extension of psd
  • -print0 prints the file names followed by a null character instead of a newline
  • | du -ch --files0-from=- takes the file names from find and computes the disk usage. The options tell du to:
    • compute the disk usage of file names separated by a null character from stdin (--files0-from=-),
    • print sizes in a human readable format (-h), and
    • print a total in the end (-c).

Change .psd to whatever file type you want to find the disk usage for.