繁体   English   中英

当在带有find的管道中使用时,`du`获取当前目录

[英]`du` takes current directory when using in pipe with find

我正在使用一个脚本,在该脚本中,我在目录(及其所有子目录)中查找文件,并打印文件+文件的大小。

就像这样:

find $folder -name $file | du --apparent-size

(使用输入$folder=folder_1$file=f1的问题是我的输出是

4   ./folder_1/f1
8   ./folder_1
13  .

find $folder -name $file的输出仅为

folder_1/f1/file1
folder_1/file1

即使没有与我的搜索匹配的文件,为什么也要使用当前目录?

尝试-exec选项:

find "$folder" -name "$file" -exec du --apparent-size '{}' \;

暂无
暂无

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

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