Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to escape & in scp

Yes, I do realize it has been asked a thousand of times how to escape spaces in scp, but I fail to do that with the &-sign, so if that sign is part of the directory name.

[sorunome@sorunome-desktop tmp]$ scp test.txt "bpi:/home/sorunome/test & stuff"
zsh:1: command not found: stuff
lost connection

The & sign seems to be messing things quite a bit up, using \& won't solve the issue as then the remote directory is not found:

[sorunome@sorunome-desktop tmp]$ scp test.txt "bpi:/home/sorunome/test \& stuff"
scp: ambiguous target

Not even by omitting the quotes and adding \ all over the place this is working:

[sorunome@sorunome-desktop tmp]$ scp test.txt bpi:/home/sorunome/test\ \&\ stuff
zsh:1: command not found: stuff
lost connection

So, any idea?

like image 230
Sorunome Avatar asked Nov 10 '15 13:11

Sorunome


People also ask

Can we escape reality?

While we may not be able to jump on the next plane to an island-getaway, we all can escape from reality mentally. Because every mind is different, it may take some trial and error to find out how you best are able to mentally escape reality.


1 Answers

Escaping both the spaces and the ampersand did the trick for me :

scp source_file "user@host:/dir\ with\ spaces\ \&\ ampersand"

The quotes are still needed for some reason.

like image 128
Aaron Avatar answered Sep 22 '22 12:09

Aaron