Tuesday, December 9, 2008

SCP fail

I was trying to copy a bunch of pdfs from my desktop to a server using scp. This command failed:

/usr/bin/scp user@example.com:~/foo/bar/*.pdf Training/


It returned a error saying "/usr/bin/scp: No match.". This is because the regex wildcard is expanded on the local machine (in this case the server) where the files are not present and therefore not found.

Whereas this one worked.
/usr/bin/scp user@example.com:~/foo/bar/\*.pdf Training/

Notice that the wildcard is now escaped so that it is ignored on the server but will be expanded when scp gets to the remote machine.

7 comments:

Anonymous said...

Thanks ! Great tip, Saved from trying to figure this out on my own

Anonymous said...

Thank you! This has been bugging me. Did a web search and found your explanation. Saved me A LOT of trouble.

Anonymous said...

Good looking out. Much appreciated.

Anonymous said...

You saved a day

Derrick Stolee said...

I also found this to be very helpful. I'm glad it is the top hit for 'scp "no match"'

Anonymous said...

Thank you for this!

Daniel Heanes said...

It's rare to look for a straightforward answer and find it straight away. Thank you :-)