Linux / Unix: Rsync Copy Files & Directories Names With WhiteSpaces and Blanks

To copy files and directories with names that contain whitespaces and blanks using rsync, you need to wrap the file or directory name in quotes. This can be done in one of the following ways:

  1. Single quotes:
rsync -av '<directory_with_whitespaces>/' <destination_directory>
  1. Double quotes:
rsync -av "<directory_with_whitespaces>/" <destination_directory>
  1. Backslash escape:
rsync -av <directory_with_whitespaces>/ <destination_directory>

The -a option tells rsync to preserve the file attributes, while the -v option provides verbose output. The <destination_directory> is the location where the files and directories will be copied to.

These methods can be used to copy files or directories with names that contain any special characters, not just whitespaces and blanks. By wrapping the file or directory name in quotes or using a backslash escape, you ensure that rsync treats it as a single entity.

Leave a Comment