find命令的性能差异

时间:2013-12-25 06:42:14

标签: shell

以下shell命令是否有任何性能差异:

find . -type f -empty -exec rm '{}' \;
find . -type f -empty -exec sh -c "/bin/rm {}" \;

1 个答案:

答案 0 :(得分:0)

你的第二个命令会变慢,因为它会为find命令找到的每个条目生成一个子shell。

然而,如果你想做一些变量赋值等,第二个命令本质上会更灵活:

find . -type f -empty -exec sh -c "x=1; /bin/rm {}" \;