Spaces in a filename when using scp

When a filename, or the path to a filename, is being used in the scp command the usual shell escaping mechanism of using a \ does not work.

To allow paths and/or filenames that have spaces to be used quote the path AND use the \ escaping.
For example

This will NOT work:

scp username@server:/directory\ name/with\ a\ filename\ with\ spaces .

The following WILL work

scp username@server:"/directory\ name/with\ a\ filename\ with\ spaces" .

HTH.

Back to GNU/Linux Command Line Tips