遍历目录并运行命令

网站管理员

我想运行以下命令

./mc cp --recursive local//first/second remote//first/second

我想遍历local//first并找到所有目录并./mc cp为每个目录运行

我怎样才能做到这一点?

塞弗

如果local//first仅包含目录,那么它应该对您有用:

./mc cp -r local//first/* remote//first

对于一般情况,您还可以使用find列出所有目录:

find local//first -type d

然后使用此列表执行任何操作,-exec或将其发送到xargs

find local//first -type d -path "local//first/*" -prune -exec ./mc cp --recursive {} remote//first \;

在文档中了解更多信息(findxargs)。

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章