find -exec 与 find | xargs 的差别 - SegmentFault
最近我想统计下,家目录下各文件(夹)的硬盘占用情况,所以用了这个命令:find -maxdepth 1 | xargs du -sh
返回的结果是,整个家目录的总大小,而不是预期的每个文件的大小。之后换用了find -maxdepth 1 -exec du -sh {} \;
就能得出每个文件的大小。
为什么使用find | xargs
得出的结果跟find -exec
不一样呢?
一个问题是,我们为什么要使用xargs?xargs对find的标准输出做了什么处理?
Read full article from find -exec 与 find | xargs 的差别 - SegmentFault
No comments:
Post a Comment