I\'m using find for a task and I noticed that when I do something like this:
find `pwd` -name \"file.ext\" -exec echo $(dirname {}) \\;
it will
$(dirname {})
is evaluated by the shell before being passed to find
. The result of this evaluation is .
, so you're just telling find
to execute echo .
for each file it finds.
basename {}
evaluates to {}
, so with $(basename {})
substituted for $(dirname {})
, find
will execute echo {}
for each file. This results in the full name of each file being echoed.
If you want to output the result of dirname
for each file found, you can omit the echo
:
find `pwd` -name "file.ext" -exec dirname {} \;