Just now, I was trying to scp a file from a remote machine to my laptop. The file path contains spaces (both directory name and file name). The normal way of escaping the spaces with backslash ‘\’ did not work with scp:
$ scp guest@remote:/some\ directory/abc\ xyz.txt ~/Desktop
Quote the whole file path also didn’t work.
$ scp guest@remote:"/some directory/abc xyz.txt" ~/Desktop
After some googling, finally, I found the following command that works:
$ scp guest@remote:"\"/some directory/abc xyz.txt\"" ~/Desktop
$ scp guest@remote:"\"/some directory\""/*.txt ~/Desktop
Like this:
Like Loading...
Related
I’ve tried a few times in the past but never could figure that one out!
Thanks, Dave
Actually, you can do it more easily by combining single and double quotes, avoiding the need to escape the double quotes. The single quotes surround the double quotes and prevent the double quotes from being interpreted by the shell:
$ scp guest@remote:'”/some directory/abc xyz.txt”‘ ~/Desktop
Thanks mate, that helped a lot.
The single quotes around the double quotes worked well – Thanks.
My destination file name also needed special characters. I found a second set of single quotes worked for the special characters in the destination name.
$ scp me@server:'”/the dir/the file (1).txt”‘ ””/a dir/the file (1).txt””
That’s
This was a Solaris 10 server with bash shell.
Post above didn’t go though right – I used angle brackets and I think they got stripped as html tags.
The destination file name reads [single][single][double][file_name][double][single][single]
can sumone suggest me out wid a simple example…..i have a presentation tomorrow……how to transfer files,,,,,???
It’s simple. I assume that you are trying to transfer files from a linux machine to a SSH server:
$ scp file1.txt file2.txt file3.txt username@servername:
The command above uses scp to transfer 3 files (file1.txt, file2.txt and file3.txt) to a machine called “servername”. The files will be placed in the home directory of the user called “username”
it always shows msg:permission denied….:-(
You need to make sure you have the permission to access the server. Try to login with the following command:
$ ssh username@servername
If you cannot login to the server (e.g. wrong username/password), then the previous scp command will also fail.