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 directory
I 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
?
print
isn't actually a standard command anywhere, and if it does exist it most likely is not a synonym forecho
. From the error message you get, your system doesn't seem to haveprint
in the path at all.find
can-print
file names for you without needing an external command anyways. Both commands you've listed are poor usage and could be replaced with a simplefind -name filename
since-print
is the default action forfind
.