繁体   English   中英

如何使用exec和du命令找出文件大小

[英]How to use exec and du command to find out size of files

我正在尝试使用find命令创建一个脚本,以在/ usr /目录中查找所有名称为bin的目录。 我也想知道每个目录的大小。 我如何使用-exec标志和du命令来做到这一点?

到目前为止,这是我设法拼凑的:

find /usr/ -name "bin" -exec 

du bin
find /usr -type d -name "bin" -exec du {} \;

以下oneliner输出目录及其总文件大小。 -c参数产生其中的文件总数。

$ 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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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