Double quotes "around complete argument.
As suggested by @dirkt in comments Quoting the complete path argument for the ssh host should do the work. That makes your command like this :
scp /home/user.name/file.html '[email protected]:/C:/Users/user.name/test folder/'
escape sequence for spacein between name of folder.
You can use
\(backslash with a space) that is escape sequence for a space. That makes your command like this :
scp /home/user.name/file.html '[email protected]:/C:/Users/user.name/test\ folder/'
\with a space in between
folderthat makes it
It maybe the case that you
need to escape twiceas It is escaped first locally and then on the remote end. In that case you can write like this :
"'complete argument'"inside quotes within double quotes like this :
"'[email protected]:/C:/Users/user.name/test folder/'"
Escape spaces and quote complete argument like this :
'[email protected]:/C:/Users/user.name/test\ folder/'
Escape twice directly using escape sequence like this
[email protected]:/C:/Users/user.name/test\\ folder/
Feel free to add-in more details.
Tried all the options above to scp from CentOS client to Windows 7 (SP1), but without success.
This one worked for me though:
$ scp /tmp/lala '[email protected]<IP>:"/Users/win7/Documents/TestComplete 14 Projects"'
The “ symbol is interpreted by bash itself. Bash decapsulates anything in between interbretes if it can and just presents the outout to a command being called as a string that may have some special symbols. Try using the apostrophe (‘) symbol for it forces bash not to look at the string at all and just pass it to a command that was invoked first.
Those strings with ‘ should be formatted like this:
If you want to see
I don’t know if this is still relevant, but one solution (that might backfire in some situations) is using “?” instead of space:
scp "[email protected]:/home/user/file?with?spaces.txt" .
Well, one more possible solution is just use Git Bash or any other bash emulator.
Then just escape all spaces with
\ before each and wrap statemens with double quotes.
This worked for me for copying a file from Ubuntu 22.04 Linux into Windows 10 (Note the command syntax was executed without SSH login and just literally running the code from windows command prompt):
scp -r "[email protected]_IP_address:Downloads/'This is some text file'" C:\Users\Admin\Downloads