How do I escape spaces in path for scp copy in Linux?

Question

I want to copy a file from remote to local system. Now I'm using scp command in linux system. I have some folders or files names are with spaces, when I try to copy that file, it shows the error message: "No such file or directory".

I tried:

scp ael5105@192.168.0.200:'/home/5105/test/gg/Untitled Folder/a/qy.jpg' /var/www/try/

I saw the some reference online but I don't understand perfectly, can any one help on this?

how can I escape spaces in file name or directory names during copying...

Answer

Basically you need to escape it twice, because it's escaped locally and then on the remote end.

There are a couple of options you can do (in bash):

scp user@example.com:"web/tmp/Master\ File\ 18\ 10\ 13.xls" .
scp user@example.com:web/tmp/Master\\\ File\\\ 18\\\ 10\\\ 13.xls .

Another option only works with older versions of OpenSSH and possibly other clients:

scp user@example.com:"'web/tmp/Master File 18 0 13.xls'" .

How can I stop redis-server?

How do I install the OpenSSL libraries on Ubuntu?