Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Problem with scp on Mac OS X: scp doesn't like spaces in filenames, "\" fix doesn't work

Tags:

path

scp

macos

ssh

I am trying to use scp to transfer files between two Macs (OS 10.6.8). But it fails because there are spaces in my directory/file names. I can't change the directory/file names.

I have often used a \ symbol when working in a terminal with my Macs to represent spaces. In this case, however, it is not working. I would very much appreciate any tips on how to deal with this. Thanks.

Here is an example of what I'm doing, in case I'm making a silly mistake somewhere:

scp -r me@myWork:../../My\ documents/Projects/Project\ 1/* ./Desktop

Error: scp: ../../My: No such file or directory

I tried rsync too and that doesn't work either:

rsync -avub -e ssh me@myWork::../../My\ documents/Projects/Project\ 1/* ./Desktop

rsync: connection unexpectedly closed (0 bytes received so far) [receiver]
rsync error: error in rsync protocol data stream (code 12) at /SourceCache/rsync/rsync-40/rsync/io.c(452)
like image 753
Ant Avatar asked Jul 14 '11 18:07

Ant


People also ask

How do you add a space in scp?

Escape Spaces with Backslash in Scp The first method to escape spaces in paths when using the scp command is to add a backslash (\) right in front of each space. Here is an example.

How do you escape space in filenames?

Three Ways to Escape Spaces on WindowsBy enclosing the path (or parts of it) in double quotation marks ( ” ). By adding a caret character ( ^ ) before each space. (This only works in Command Prompt/CMD, and it doesn't seem to work with every command.) By adding a grave accent character ( ` ) before each space.

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

Put the quotes around the whole path, including the login name and ip address. Alternatively, remote the quotes and prepend the space with a backslash instead.

How do I scp a directory?

To copy a directory (and all the files it contains), use scp with the -r option. This tells scp to recursively copy the source directory and its contents. You'll be prompted for your password on the source system ( deathstar.com ). The command won't work unless you enter the correct password.


2 Answers

for me I needed to actually do both:

scp -r 127.0.0.1:/Volumes/Folders/Faces/"Why\ Spaces\ Why"/"Insanity\ Rules"/ .
like image 155
BrianBlaze Avatar answered Oct 16 '22 12:10

BrianBlaze


This worked for 10.14.5 Mojave and 10.15.7 Catalina

scp -r [email protected]:~/Library/MobileDevice/"Provisioning\ Profiles"/. ~/Library/MobileDevice/"Provisioning Profiles"/.

Note:

the source path has "Provisioning\ Profiles"

the destination path has "Provisioning Profiles"

like image 31
Ted Avatar answered Oct 16 '22 14:10

Ted