I'm trying to create a script with the find command to find all directories with the name " bin " within the " /usr/ " directory. I also want to know the size of each of these catalogues. How would I do this by using the -exec flag and du command?
This is what I've managed to scrape together so far:
find /usr/ -name "bin" -exec
du bin
find /usr -type d -name "bin" -exec du {} \;
The following oneliner outputs the directories and their total file sizes. The -c
argument produces the grand total of the files inside.
$ find /usr -type d -name bin -exec du -shc {} +;
104K /usr/src/gcc/contrib/reghunt/bin
67M /usr/bin
8.4M /usr/local/bin
75M total
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.