[英]scp a bunch of files via bash script: there must be a better way
I currently have the following bash script: 我目前有以下bash脚本:
for a in `seq 16 75`;
do scp doneill@server:/mnt/device/folder/numbered_file$a.txt ./;
done;
while this does work, it is very slow. 虽然这确实有效,但速度非常慢。 Each file, the request to the sever takes about 4-7 seconds, then sending the file takes another 3 or so seconds.
每个文件,对服务器的请求大约需要4-7秒,然后发送文件需要另外3秒左右。
Is there a way to do this that involves only 1 command sent to the server (to minimize the time my VPN spends sending receiving each individual command)? 有没有办法做到这一点只涉及发送到服务器的1个命令(以最小化我的VPN花费发送接收每个单独命令的时间)? Normally, I would do something like
scp doneill@server:/mnt/device/folder/numbered_file*
but there are many thousands of files in the folder that I don't want to copy. 通常情况下,我会做一些像
scp doneill@server:/mnt/device/folder/numbered_file*
但scp doneill@server:/mnt/device/folder/numbered_file*
有数千个我不想复制的文件。 I need to get only those few (defined by the sequence). 我只需要那些少数(由序列定义)。
在bash中:
scp doneill@server:/mnt/device/folder/numbered_file{16..75}.txt ./
rsync should do the trick: http://www.manpagez.com/man/1/rsync/ rsync应该做的伎俩: http : //www.manpagez.com/man/1/rsync/
You may have to fiddle a bit with the parameters, but done right, it's probably the fastest way of transferring files over ssh. 您可能不得不对参数进行一些调整,但做得恰到好处,这可能是通过ssh传输文件的最快方法。
这适用于bash吗?
scp doneill@server:/mnt/device/folder/numbered_file{16..75}.txt ./
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.