How to Copy a File with SCP with Special Characters

scp

I am trying to copy a file that has colons and periods, e.g., with:

scp "test.json-2014-08-07T11:17:58.662378" remote:tmp/

scp test.json-2014-08-07T11\:17\:58.662378 remote:tmp/

and combinations with file:

scp "file:///home/.../test.json-2014-08-07T11:17:58.662378" remote:tmp/

My guess is that scp tries to interprete parts of the file as a server and/or port number. How do I avoid that?

If I rename the file to test.json then scp test.json remote:tmp/ works ok, but not even scp test*62378 remote:tmp/works.

Best Answer

Use ./ before your filename:

scp ./test.json-2014-08-07T11:17:58.662378 remote:tmp/

That make scp know it's a file. Without it, scp thinks it's a hostname because of the colon.

Related Question