The immediate error is from using ${...}
in place of a command substitution, $(...)
. However, you also don't generally want to inject the pathname into the in-line shell script using {}
, but instead to pass it as an argument to bash -c
:
find ./1cv8 -maxdepth 1 -type d -exec bash -c '
echo vrunner -src "$1" \
-o "./builds/$(basename "$1")"
' bash {} \;
or, for a slight speed increase from not starting a new shell for each match,
find ./1cv8 -maxdepth 1 -type d -exec bash -c '
for pathname do
echo vrunner -src "$pathname" \
-o "./builds/$(basename "$pathname")"
done' bash {} +
This way, you will have no issues with names containing quotes or things that the shell will interpret as expansions, redirections, pipes etc., as the pathname is no longer injected and used as shell code.
Note that I deleted your -wholename
test as it would always be true.
See also:
In the bash
shell, since you don't actually use find
to locate the directories in any other directory than in the top-level one:
shopt -s nullglob dotglob
for pathname in ./1cv8/*; do
if [ ! -d "$pathname" ] || [ -L "$pathname" ]; then
# skip oven non-directories and symbolic links
continue
fi
echo vrunner -src "$pathname" \
-o "./builds/$(basename "$pathname")"
done
$(basename "{}")
? – Bodo Oct 02 '23 at 10:21