Finding disk usage by file type

G

gatorparrots

Guest
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.
 
OP
K

Kris

Guest
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. :)
 

Shop Amazon


Shop for your Apple, Mac, iPhone and other computer products on Amazon.
We are a participant in the Amazon Services LLC Associates Program, an affiliate program designed to provide a means for us to earn fees by linking to Amazon and affiliated sites.
Top