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.
Answers:
Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.
Method 1
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.
Method 2
Use the path by prepending ./ and escape your :‘s. Cyberiti has more info. Example:
scp ./file:with:colons.txt remoteserver:
Method 3
Apparently, I did not try this version with path prefix:
scp /home/.../test.json-2014-08-07T11:17:58.662378 remote:tmp/
this also works:
scp ./test.json-2014-08-07T11:17:58.662378 remote:tmp/
From https://twitter.com/h0pbeat/status/497319751031353344 and http://www.cyberciti.biz/faq/rsync-scp-file-name-with-colon-punctuation-in-it/ Thanks.
(as the above users managed to answer before me)
All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0