Can I do an inclusive du, as opposed to exclusive?

0

I need to do a du search that only grabs certain subfolders. For example, here is the directory structure:

du -b

0   ./678  
21  ./679/536/Content_Repository_PoC_-_Main  
73  ./Content_Repository_PoC_-_C-CDN_JIT_Packaging/679/536  
255034  ./PoC_-_C-CDN_JIT_Packaging/680/13/processed_3348d8a9-a  
201034  ./PoC_-_C-CDN_JIT_Packaging/683/13/processed_cec582f5-1  
208034  ./PoCx/225/processed_cec27825-1

I need it to return the sum total ONLY of the subfolders with the word "processed" in the subfolder name (so in this example, only the bottom three). I can expect a massive number of positive results.

In other words, rather than du --exclude='processed*', I would want something like

du --exclude!='processed*'

CaptainSkyfish

Posted 2017-10-23T23:04:48.127

Reputation: 101

Answers

0

With find:

find -type d -name 'processed*' exec du {} \;

If you want the total size:

find -type d -name 'processed*' exec du -c {} +

('+' has all the matching files processed with one single command)

If all your 'processed*' are at the same directory level you can also avoid find with some shells (bash, zsh):

du -c */*/processed*

xenoid

Posted 2017-10-23T23:04:48.127

Reputation: 7 552

Thank you, but with that find command I received "find: Arguments to -type should contain only one letter." I should note this is on Red Hat Enterprise 6.6. – CaptainSkyfish – 2017-10-24T15:35:56.050

I actually ended up getting it to work with a modified "find -name processed* -exec du -bs {} +" – CaptainSkyfish – 2017-10-24T16:03:17.513

Fixed the commands... mean find -type d – xenoid – 2017-10-24T20:06:55.990