SCP and path with spaces? (another "waste of time issue")

Guest Author

Sometimes, you need to deal with a really time-wasting issue. I think it happens even more often if you work in the IT industry. You know the resolution must be simple, but all your attempts failed. So you try to search the web, looking for a plain sentence that will lead you out of that mess...

If you want to copy a file using SCP and the remote path contains spaces, you do it this way:

scp -r username@servername:"/some/path\\\\ with\\\\ spaces" .

Everything you need to do is to enclose the path in double quotes and use double backslash on spaces...

Join the discussion

Comments ( 3 )
  • Marc Friday, March 27, 2009

    For completeness, note that you can also use triple \\\\\\ without quotes, or if you are using a good shell like zsh you can press TAB and let completion do the job.

  • TheDeath Tuesday, December 14, 2010

    Thanks, was wondering for ages how to get that to work.


  • orion Saturday, December 25, 2010

    A single backslash and no quotes work just fine for me.

Please enter your name.Please provide a valid email address.Please enter a comment.CAPTCHA challenge response provided was incorrect. Please try again.