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?

3 Answers 3


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.

  • 1
    how to sort the output by size?
    – ulkas
    Sep 15, 2015 at 7:48
  • 1
    To sort it by size, I added (just after =-) a space and then | sort -h
    – OldGrampa
    Aug 1, 2020 at 22:19

More generically, you could use a combination of find and awk to report disk usage grouping by any rule you choose. Here's a command that groups by file extensions (whatever appears after the final period):

# output pairs in the format: `filename size`.
# I used `nawk` because it's faster.
find -type f -printf '%f %s\n' | nawk '
    split($1, a, ".");       # first token is filename
    ext = a[length(a)];      # only take the extension part of the filename
    size = $2;               # second token is file size
    total_size[ext] += size; # sum file sizes by extension
  END {
    # print sums
    for (ext in total_size) {
      print ext, total_size[ext];

Would produce something like

wav 78167606
psd 285955905
txt 13160

Yeah, you can. The syntax for searching files in terminal is:

Syntax   :   find foldername -iname '.filetype' -size size 

Example  :   find $HOME -iname '*.mp3' -size +1M

For your scenario it has to be like

find $HOME -iname '*.psd' -size +0M

For more information see official document here.

  • Yes but this will only print the file names that are +0M, it won't actually tell me their size.
    – Alaa Ali
    Dec 10, 2014 at 22:01
  • Yes, I saw your answer perfect!
    – PAC
    Dec 10, 2014 at 22:32

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .