Search code examples
bashshellfindls

find exec ls : No such file or directory


I tried to execute:

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

And it printed:

find: 'ls -la /home/users/MyUser/fooBar': No such file or directory

find: 'ls -la /home/users/MyUser/Barfoo': No such file or directory

Also ls is aliased to ls --color.

What kind of tricky trick happened here?


Solution

  • The arguments of -exec should not be quoted. Remove the quotes after -exec. And -exec does not detect aliases so you need to pass the --color option to exec.