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*'

1 Answer 1

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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .