I thought the following two commands would output the same thing, but they don't:Command 1:find . -name filename -exec print '{}' \;Command 2:find . -name filename -exec echo '{}' \;In fact, Command 2 works as I expected it to work: it prints the relative path to all instances of filename under .However, for Command 1 I get as many lines in the output as I get for Command 2, but instead of giving me the path, each line says:find: print: No such file or directoryI have also tried removing the quotes fron {}. Why doesn't the second command work as I expected it to work? And why does it fail to print the path to each instance of filename?
find -exec on zsh: echo works as expected, print doesn't
find;zsh
Contrast:% whence -a printprint% whence -a echoecho/bin/echoThis shows that print only exists as a built-in, whereas echo exists both as a built-in and an executable. (Actually, going by what's shown above, print and echo could be aliases, functions or reserved words; use whence -w to see precisely what type of internal object a name represents.)find is an external command, so it can't invoke any shell built-in. If you really need to invoke your shell's built-ins, invoke a shell explictly:find . -name filename -exec zsh -c 'print $0' '{}' \;In this case, I don't think you want zsh's print built-in: find's -print primary will do the job, only properly (the zsh print built-in expands backslashes).find . -name filename -print(You can even leave out the -print here, because -print is the default action for find when no action is specified.)The reason why there is an echo external executable but none called print is that echo is a standard command, so it's given maximum availability even to programs that want to invoke it without going via a shell. In contrast, print is specific to zsh, so only zsh scripts use it in the first place.(Oh, and on my system, there is a print command, which sends files to the printer.)