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
It showing you the dots, because the process substitution is evaluated before the command is actually executed. So you've to pass your command into separate shell instance.
As for workaround, use the following syntax:
find $PWD -name "file.ext" -exec sh -c 'echo $(dirname {})' ';'
However the easiest way to print or execute something in each directory is by -execdir
, e.g.:
find . -name "file.ext" -execdir pwd ';'