Linux – How to escape spaces in path for scp copy in Linux

linuxscpUbuntuunixwhitespace

I'm new to linux, 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…

Best 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" .
scp user@example.com:web/tmp/Master\\\ File\\\ 18\\\ 10\\\ 13.xls .