Lets say we want to exclude all the *.png files while calculating the file space usage.
[shredder12]$ du -h --exclude=*.pngThe --exclude option takes a wildcard as input.
399M
[shredder12]$ du -sh
513M
[shredder12]$ du -ch *.png
…
115M total
The -h option is to show the size in a human readable format rather than a huge figure in bytes.
The -c option is used to add an extra line showing the grand total of all the files.
If the files to be excluded don’t match any pattern then one can create a list of all the filenames and pass the file containing that list as argument to du’s --exclude-from option.
Say we have the list in the file named “list”.
REFERENCES
http://linuxers.org/article/how-exclude-set-files-disk-space-usage-calculation-using-du