how to use SCP if the filename has spaces

Hi,

On the source computer have a filename like this:

/cygdrive/c/My\ Documents/file.txt

I would like to like to copy this file to another computer.  Here's the command that I tried to use:

scp bryanh@source:/cygdrive/c/My\ Documents/file.txt ./file.txt

However, the computer gives me an errorwhich says something like this:

/cygdrive/c/My: file not found
Documents/file.exe: file not found

Can anyone tell me how to use this command when the filename has a space inside of it?

LVL 3
bryanlloydharrisAsked:
Who is Participating?
 
devrick0Commented:
You should give it a try with quotes, that works for me.

scp user@host:"/cygdrive/c/Documents\ and\ Settings/user/My\ Documents/test\ file.txt" .
0
 
bryanlloydharrisAuthor Commented:
So you use quotes, but you also use the escape sequences for the spaces?  I will try this.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.