PDA

View Full Version : Finding disk usage by file type



gatorparrots
12-23-2002, 05:34 PM
You can easily find the disk usage by file type with this simple one-liner command.
sudo find / -name "*.mp3" -print0 | xargs -0 du -ck
This will calculate the disk usage of all of your mp3 files.

To make it more fun, throw an alias into your .*shrc file like so:
alias diskspc 'sudo find / -iname "*\!:1*" -print0 | xargs -0 du -cks'
This will net you the ability to search for any file type. For example issuing,
diskspc .tif would return the filesize for every tiff file, whether its extension .tif, .TIF, .tiff, or .TIFF.
(Note the case insensitivity provided by the -iname flag. Very handy for this application.)

Also, if you have fileutils installed, replace the flag on du with this one: du -chs
This will return the results in human-readable MB, instead of KB.

Kris
12-23-2002, 07:34 PM
Originally posted by gatorparrots@Dec 23 2002, 09:34 PM
sudo find / -name "*.mp3" -print0 | xargs -0 du -ck
This will calculate the disk usage of all of your mp3 files.

Very neet, thanks. :)