tony arkles blog

Here’s a stupid unix trick: scp is an awesome tool for moving files around between unix-y machines (for instance, my Mac laptop and my Linux HTPC). Often enough, though, I need to copy a file with a space in the name, and this stumped me for a while.

Here’s the answer. You need to quote it twice:

scp username@192.168.1.2:"'my file has spaces in it'" .

The first set of quotes protects the second set of quotes from the shell, so the file name gets passed over ssh with the quotes still in it… then the shell on the other end sees the quotes and removes them (preserving the spaces).