使用scp递归复制dir时如何过滤文件? [英] How to filter files when using scp to copy dir recursively?

查看:128
本文介绍了使用scp递归复制dir时如何过滤文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要将所有.class文件从服务器复制到本地,并保留所有目录。例如服务器:/usr/some/unknown/number/of/sub/folders/me.class 将是 / usr / project / backup / some /问题是未知的/数量/子目录/文件夹/me.class ,还有很多其他我不想使用的无用文件,例如.svn-base文件。我该如何过滤它们,以便仅使用 scp .class文件?

I need to copy all the .class files from server to local with all dir reserved. e.g. server:/usr/some/unknown/number/of/sub/folders/me.class will be /usr/project/backup/some/unknown/number/of/sub/folders/me.class the problem is, there are many other useless files such as .svn-base files that i don't want. how can i filter them so I only scp .class files?

推荐答案

为此,我可能建议使用 rsync 之类的东西到 include exclude 标志,例如:-

I'd probably recommend using something like rsync for this due to its include and exclude flags, e.g:-

rsync -rav -e ssh --include '*/' --include='*.class' --exclude='*' \
server:/usr/some/unknown/number/of/sub/folders/ \ 
/usr/project/backup/some/unknown/number/of/sub/folders/

一些其他有用的标志:


  • - r 用于递归

  • -a 用于存档(主要是所有文件)

  • -v 用于详细输出

  • -e 指定ssh而不是默认值(实际上应该是ssh)

  • -r for recursive
  • -a for archive (mostly all files)
  • -v for verbose output
  • -e to specify ssh instead of the default (which should be ssh, actually)

这篇关于使用scp递归复制dir时如何过滤文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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