我想通过找到一些目录
find /path/to/a/dir -type d -links 2
然后对于由发现的每个路径名(find
假定存储在变量中)pathname
,我想
stow -d "$(dirname "$pathname")" -t /home/t/bin "$(basename "$pathname")"
如何将以上内容与结合使用find -exec
,类似于:
find /path/to/a/dir -type d -links 2 -exec stow -d "$(dirname \{\})" -t /home/t/bin "$(basename \{\})" \;
我认为它不起作用,因为外壳程序在运行之前执行命令替换find
,并且在命令替换中未找到要替换的路径名\{\}
。
谢谢。
您将其包装在sh -c
命令中
find /path/to/dir -type d -links 2 -exec sh -c 'stow -d "$(dirname "$1")" -t /home/t/bin "$(basename "$1")"' sh {} \;
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句