0

Suppose I have files numbered 1.txt through 5000.txt on a server and I want to copy files numbered 1800.txt through 5000.txt to my local system. How do I do that? Normally, for copying all, I would use scp -r but that won't work for this.

2
  • 1
    You can use wildcards. Aug 24, 2018 at 17:55
  • I am not familiar with that. Can you elaborate? Aug 24, 2018 at 17:56

2 Answers 2

2

try

scp user@host:/path/to/remote/'{1800..5000}.txt' /path/to/local

we quote the brace-expansion to prevent interpret that by your local servers' shell; instead it will expand by remote servers' shell.

0
0

With a shell that supports "brace expansion" (e.g. bash or ksh), you could try

scp user@$remotehost:{1800..5000}.txt /local/path
3
  • I think your answer is saying the same as mine but yours will fail as your local server shell will expend the brace-expansion or am I missing something here different? Aug 24, 2018 at 19:12
  • No it doesn't fail. I was thinking the same with your quoted brace expression. But it seems both are working; admittedly yours is faster as it hands the brace expression to the remote server... hopefully the shell over there knows how to expand it.
    – RudiC
    Aug 24, 2018 at 19:32
  • ah, right, in your case it expands all to like scp user:host:1800.txt user@host:1801.txt ... user@host:5000.txt /local/path that's why it's slow Aug 24, 2018 at 19:42

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .