bash - Check sizes for a groups of folders (grouped by some pattern) -


i have folder contains many other folders, suffixes fox example test.folder-1-2-3 , test.folder-1-2-4 ..there more folders same suffix , count sizes of folders of same suffix , count suffixes. made this. created array suffixes stored , in cycle perfoming du command check size each suffix , use awk sum it. unfortunately takes hours , hours unusable me.. suggestions how faster? thanks,

list=($(ls /folder/where/others/are | grep "folder.which.exists.for.all.suffixes" | sort -u | cut --delimiter="-" -f5-9));   echo ${list[@]};  (( = 0 ; < ${#list[@]} ; i++ )); temp=${list[$i]} echo checking size of folder containing: $temp du -s /folder/where/others/are |grep $temp |awk '{sum +=$1};end {print "total size is:" sum*512 "[b]" }' 

done

to sum sizes of dirs suffix $suf:

find . -type d -name "*$suf" | xargs du  | awk '{print $1}' | paste -sd+ - |  bc 

Comments

Popular posts from this blog

.htaccess - First slash is removed after domain when entering a webpage in the browser -

Automatically create pages in phpfox -

c# - Farseer ContactListener is not working -