how to use SCP if the filename has spaces


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?

Who is Participating?
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" .
bryanlloydharrisAuthor Commented:
So you use quotes, but you also use the escape sequences for the spaces?  I will try this.
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.