特定文件递归复制在Unix / Linux操作系统?

编程入门 行业动态 更新时间:2024-10-28 11:32:07
本文介绍了特定文件递归复制在Unix / Linux操作系统?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我需要复制所有的 *。JAR从目录文件及其所有子目录。我怎样才能做到这一点在UNIX / Linux终端?命令 CP -r的* .jar / destination_dir 不起作用。

I need to copy all *.jar files from directory and all its subdirectories. How can I do it in UNIX/Linux terminal? Command cp -r *.jar /destination_dir doesn't work.

推荐答案

的rsync 是本地文件的复制以及机器间有效。这将做你想要什么:

rsync is useful for local file copying as well as between machines. This will do what you want:

rsync的-avm --include ='*。JAR-f隐藏,! * /。 / destination_dir

从整个目录结构。被复制到/ destination_dir,但只有.jar文件被复制。使用-a保证了文件的所有权限和时间不变。该-m会忽略空目录。 -v是详细的输出。

The entire directory structure from . is copied to /destination_dir, but only the .jar files are copied. The -a ensures all permissions and times on files are unchanged. The -m will omit empty directories. -v is for verbose output.

有关预演添加-n,它会告诉你什么会做,但实际上没有复制任何东西。

For a dry run add a -n, it will tell you what it would do but not actually copy anything.

更多推荐

特定文件递归复制在Unix / Linux操作系统?

本文发布于:2023-10-09 09:23:32,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1475349.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:递归   操作系统   文件   Unix   Linux

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!