特定文件递归复制在Unix / Linux操作系统? [英] Recursive copy of specific files in Unix/Linux?

查看:270
本文介绍了特定文件递归复制在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操作系统?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆