开发者

scp a bunch of files via bash script: there must be a better way

I currently have the following bash script:

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.

Is there a way to do this that involves only 1 command sent to the server (to minimize the time my VPN spends sending receiv开发者_C百科ing each individual command)? 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. I need to get only those few (defined by the sequence).


In bash:

scp doneill@server:/mnt/device/folder/numbered_file{16..75}.txt ./


rsync should do the trick: 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.


Does this work with bash?

scp doneill@server:/mnt/device/folder/numbered_file{16..75}.txt ./
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜