how to use SCP if the filename has spaces

Posted on 2006-05-31
Last Modified: 2013-12-16

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?

Question by:bryanlloydharris
    LVL 5

    Accepted Solution

    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" .
    LVL 3

    Author Comment

    So you use quotes, but you also use the escape sequences for the spaces?  I will try this.

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Join & Write a Comment

    In this tutorial I will explain how to make squid prevent malwares in five easy steps: Squid is a caching proxy for the Web supporting HTTP, HTTPS, FTP, and more. It reduces bandwidth and improves response times by caching and reusing frequently-…
    Using 'screen' for session sharing, The Simple Edition Step 1: user starts session with command: screen Step 2: other user (logged in with same user account) connects with command: screen -x Done. Both users are connected to the same CLI sessio…
    Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
    Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

    745 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    16 Experts available now in Live!

    Get 1:1 Help Now