简体   繁体   中英

how to see all directory sizes named invoices in a bash script

I have a list of directories and was wondering if there was a bash script to do maybe a for loop to go through and enter du -h at the last directory ( /something/something/invoices ). Or is there a better command to do than: find / -type d -name "/something/something/invoices" -ls that would include the invoices directory sizes.

Thank you and hope to hear from someone.

If invoices can appear on any depth in the subtree, use find 's -exec option:

find / -type d -name invoices -exec du -h {} \;
3,5M    /here/there/invoices
1,6M    /somewhere/else/invoices
560K    /nested/really/really/really/deep/invoices
:

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM