I'm trying to scp a file from my local linux machine to a remote Windows machine, and I'm coming up with some inconsistencies in how scp handles Windows file paths with spaces...
This works, note that spaces are properly escaped in the path to the local file:
scp /home/will/file\ with\ spaces.txt remote@host:D:/Users/will/Downloads/
However, this does not work, despite the space in the "Google Drive" folder being properly escaped:
scp /home/will/file\ with\ spaces.txt remote@host:D:/Users/will/Google\\ Drive/Documents/Computer_Stuff/Home_Lab/folder
I've gone through a ton of resources online where people have similar problems, and all their solutions didn't work for me.
I tried putting the Windows file path in double quotes, single quotes, both with and without escaping spaces; I've tried using double \\
and triple \\\
to escape spaces; I even tried escaping the colon (D\:
); and I tried explicitly stating a target filename and not. Nothing worked.
Then I found this answer, and only method #2 works! Why? What is the difference between surrounding the Windows file path in '"
, and "'
? Why can I simply escape spaces without using any quotes at all in the local Linux file path, but not in the remote Windows path?
'remote@host:D:/Users/will/Google Drive/Documents/...'