Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Anyone who's ever SCP'd knows that this probably doesn't work:

scp foo.txt ' bar.txt'

For me on this one, I get: "ambiguous target".

The man page for SCP doesn't explain why you need to escape that space, yet the argument seems to fit the specification for that argument listed in the man page:


Seems to match, to me. So, why is it required to do this:

scp foo.txt '\ bar.txt'
share|improve this question
up vote 11 down vote accepted

In the first case, you are specifying two files as copy target, both residing on This is clearly ambiguous, as the program cannot determine where to copy the file.

Consider the following, working example specifying two source files and one destination (directory) using the same format:

scp ' file2' .

This will copy both file1 and file2 from to the local directory.

Your local scp program connects to the remote host and starts another instance of of scp with a parameter determining whether you're transferring files from it (-f), or to it (-t). You can see this when you add the argument -v for verbose output. The source/destination parameter you enter (host:file) is split and the file names part simply appended as additional parameters specifying the files to use.

When using it as source:

debug1: Sending command: scp -v -f -- file1 file2

This works without problem, it transfers multiple source files over the network.

When using it as sink:

debug1: Sending command: scp -v -t -- file1 file2

This fails, as you're intending to write to multiple files. Now the way around this is to escape the file name again (once for the local shell, once for the remote call):

$ scp foo '\ bar'
debug1: Sending command: scp -v -t -- foo\\ bar

And FWIW, scp foo '"foo bar"' works just as well.

share|improve this answer
When viewing the verbose output it's obvious that this is much more efficient than the otherwise equivalent scp . – Daniel Beck Feb 11 '13 at 23:18
Seems to me that the SCP man page ought to use "files", if more than one can be specified. There is a curious ..., and that might indicate more than one file, but I took it as "more stuff in other arguments" and opposed to "more stuff in this argument". – Thanatos Feb 11 '13 at 23:45

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .