I would like to find some directories via
find /path/to/a/dir -type d -links 2
and then for each pathname found by find
, assumed to be stored in variable pathname
, I would like to
stow -d "$(dirname "$pathname")" -t /home/t/bin "$(basename "$pathname")"
How can I combine the above with find -exec
, something similar to:
find /path/to/a/dir -type d -links 2 -exec stow -d "$(dirname \{\})" -t /home/t/bin "$(basename \{\})" \;
I think it doesn't work because the shell performs the command substitutions before running find
, and no pathname is found yet to replace \{\}
in the command substitutions.
Thanks.
sh
instead ofbash
here? – Tim Dec 02 '18 at 14:14sh
is guaranteed to exist on any Unix system. Onlinux
,/bin/sh
is either a symlink to/bin/bash
itself (eg. rhel, centos) or to something smaller and faster (/bin/dash
on ubuntu and debian). – Dec 02 '18 at 14:28