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*'
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*
  • 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 Oct 24 '17 at 15:35
  • I actually ended up getting it to work with a modified "find -name processed* -exec du -bs {} +" – CaptainSkyfish Oct 24 '17 at 16:03
  • Fixed the commands... mean find -type d – xenoid Oct 24 '17 at 20:06

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.