October 10, 2006

Copying files with colons using scp or rsync


OpenSSH
Seems that there's a lot of people out there that do not know how to copy a file with a colon in it's name (for example a:a.txt) using scp or rsync, so here's an explanation:

The trick is to know where you're using the : character. If it's a remote file there's no problem and no need of escaping since you preceded already by an :. Example:

scp me@my.machine.com:a:a.txt .

If it's a local file you just have to say it explicitly by expressing a path. Example:

scp ./a:a.txt me@my.machine.com:

This works for me at least on OpenSSH 4.3.

2 comments:

  1. Anonymous11:44 PM

    mv a:a.txt a_a.txt
    scp a_a.txt me@my.machine.com:
    ssh me@my.machine.com mv a_a.txt a:a.txt

    ehehehheeh... pronto, pronto... :-D

    ReplyDelete
  2. While being a bigger line is fine for me, having to insert my password twice isn't really that fun :-P

    ReplyDelete