find exec ls:没有这样的文件或目录

A. *_*lle 4 bash shell ls find

我尝试执行:

find ~/ -name "*foo*" -exec "ls -la {}" \;

它打印了:

find: 'ls -la /home/users/MyUser/fooBar': 没有这样的文件或目录

find: 'ls -la /home/users/MyUser/Barfoo': 没有这样的文件或目录

ls别名为ls --color.

这里到底发生了什么诡计呢?

ser*_*gio 5

的论点-exec不应被引用。删除后面的引号-exec。并且-exec不检测别名,因此您需要将--color选项传递给 exec。