r ... but leave out (exclude) a specified subdirectory
Here's the directory structure:
/a/
/a/b/
/a/c/
I want to copy everything, EXCEPT for the /a/c/ subdirectory.
scp -rp myserver:/a . # this will copy everything
Q: How would I specify a directory to leave out in the scp command ?
I don't think you can, but you could use rsync? Something like this:
rsync -a --exclude=a/c myserver:/a .
I think this might be the correct way of doing it so you are still using SSH, I haven't found a way to do it with scp - but using rsync over ssh might resolve it.
rsync -e 'ssh -ax' -av --exclude /a/c myserver:/a .
If you use the -n switch then it will create a dry run of the process:
rsync -e 'ssh -ax' -av --exclude /a/c -n myserver:/a .
您可以使用如下例所示的扩展匹配:
#Enable extglob
shopt -s extglob
cp -rv !(./excludeme/*.jpg) /var/destination
链接地址: http://www.djcxy.com/p/78140.html
上一篇: 递归复制文件夹,排除一些文件夹
下一篇: r ...但省略(排除)指定的子目录