Archive for September, 2007

Using scp to copy files/directories with spaces in their names

Friday, September 7th, 2007

While trying to copy a directory recursively from one machine to another on a network using the scp command I ran into a problem I have never encountered before. I suspected that the spaces in the directory name were causing the problem so I tried the usual escaping options. First I tried escaping with quotes:

$ scp -r user@ip1:~/tmp/"The Office Season 3"/ user@ip2:~/tmp/

That didn’t work, so I tried escaping with escape characters:

$ scp -r user@ip1:~/tmp/The\ Office\ Season\ 3/ user@ip2:~/tmp/

Same result. After searching online I found a post that suggested trying both at the same time:

$ scp -r user@ip1:~/tmp/"The\ Office\ Season\ 3"/ user@ip2:~/tmp/

That did it! Check out the scp man page for more on using scp.