scp file with spaces in the filename

on

When trying to scp a file with spaces next command will not work:

scp user@server:/home/user/file with spaces ./

There are two way to solve this:

use quotes, embed file name with outer double quotes and inner single quotes.

scp user@server:/home/user/"'file with spaces'" ./

Another method is escaping (still needs double quotes, but spaces are escaped with an \):

scp user@server:/home/user/"file\ with\ spaces" ./

Result:

file with spaces                        100%   14KB  14.4KB/s   00:00