TZJ
TZJ

Reputation: 159

Bash scp failure?

For example I'm trying to do a simple scp:

scp [email protected]:/home/tzj21/scratch/McAdam/chains/z0.5/temp_cc1/* .

It fails when there are obviously files in the folder and simply returns scp: No match.? I'm fairly sure this used to work before. When I try:

scp [email protected]:/home/tzj21/scratch/McAdam/chains/z0.5/temp_cc1/1.txt .

it works just fine. Is this to do with the server I'm trying to scp to preventing me from transferring all files?

Edit: Solved. Main problem was me being inside tcsh rather than bash.

Upvotes: 0

Views: 326

Answers (2)

character
character

Reputation: 310

Maybe this will do it.

You must pass a literal escape to scp so that the remote machine does not consider it a glob.

exmaple>

scp [email protected]:/home/tzj21/scratch/McAdam/chains/z0.5/temp_cc1\* .
scp [email protected]:/home/tzj21/scratch/McAdam/chains/z0.5/temp_cc1* .

Upvotes: 1

heemayl
heemayl

Reputation: 42007

You need to expand * (to all files) on the remote shell, not on the local shell.

Any regular escaping method to prevent pre-expansion of * on the local shell would do:

scp [email protected]:/home/tzj21/scratch/McAdam/chains/z0.5/temp_cc1/'*' .
scp [email protected]:/home/tzj21/scratch/McAdam/chains/z0.5/temp_cc1/"*" .
scp [email protected]:/home/tzj21/scratch/McAdam/chains/z0.5/temp_cc1/\* .

Or you can quote the whole filename string as well:

scp [email protected]:'/home/tzj21/scratch/McAdam/chains/z0.5/temp_cc1/*' .
scp [email protected]:"/home/tzj21/scratch/McAdam/chains/z0.5/temp_cc1/*" .

Upvotes: 2

Related Questions