How to filter files when using scp to copy dir recursively?

前端 未结 9 1293
醉酒成梦
醉酒成梦 2021-01-29 20:00

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/proj

9条回答
  •  故里飘歌
    2021-01-29 20:30

    There is no feature in scp to filter files. For "advanced" stuff like this, I recommend using rsync:

    rsync -av --exclude '*.svn' user@server:/my/dir .
    

    (this line copy rsync from distant folder to current one)

    Recent versions of rsync tunnel over an ssh connection automatically by default.

提交回复
热议问题