20

Other than by renaming the files first, how can I rsync files that may have colons in their names?

  • Make sure you are using dir/ and not dir/* in rsync arguments. – grawity Apr 19 '11 at 20:19
  • The problem happens when I rsync from a hard drive to a flash memory stick: rsync: mkstemp "/media/verd/rence/.Using an expressive work: fact or fiction.pdf.RbjlKK" failed: Invalid argument (22) rsync: mkstemp "/media/verd/rence/.What's in a concept: structural foundations for semantic networks.pdf.tLXoZz" failed: Invalid argument (22) – 象嘉道 Apr 20 '11 at 18:40
20

Colons are only special in the first directory component of a command line argument. So if you have what looks like a relative path, prepend ./.

$ mkdir sou:rce
$ rsync -a sou:rce/ de:st/
The source and destination cannot both be remote.
$ rsync -av ./sou:rce/ ./de:st/
sending incremental file list
created directory ./de:st
./

In a script:

case $source in
  /*) :;;
  *) source=./$source;;
esac
case $dest in
  /*) :;;
  *) dest=./$dest;;
esac
rsync "$source" "$dest"
  • Thank you, Guilles. The problem happens when I rsync from a hard drive to a flash memory stick: rsync: mkstemp "/media/verd/rence/.Using an expressive work: fact or fiction.pdf.RbjlKK" failed: Invalid argument (22) rsync: mkstemp "/media/verd/rence/.What's in a concept: structural foundations for semantic networks.pdf.tLXoZz" failed: Invalid argument (22) – 象嘉道 Apr 20 '11 at 18:36
  • 3
    @Kejia柯嘉: Ah, ok, your problem is to rename-and-rsync, not to pass the colons to rsync. This question came up before on the Ubuntu site: How can I substitute colons when I rsync on a USB key? Unfortunately no one's produced a satisfying answer. – Gilles Apr 20 '11 at 18:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.