Copy multiple sources to multiple destinations simultaneously

6,102

If you want to transfer a selection of files via rsync, i.e. not the entire directory including contents, then the best way of doing so is by using rsync's --files-from option. Place the pathnames of the files you want to transfer, relative to the source directory you specify. See rsync's manpage for more detailed information.

Share:
6,102

Related videos on Youtube

Nemoden
Author by

Nemoden

Updated on September 18, 2022

Comments

  • Nemoden
    Nemoden over 1 year

    Suppose I need to copy files

    ~/path/to/file to user@remote:/path/to/file

    ~/path/to/another/file to user@remote:/path/to/another/file

    ~/path/alternative to user@remote:/path/alternative

    Is there is a way to do this using rsync or scp?

    I've tried rsync ~/path/{to/file,to/another/file,alternative} user@remote:/path

    But it's not an option if I need to copy to another dest like another_path.

    Copying file-by-file is way too long if I need to copy at least 20 files.

    • wurtel
      wurtel over 9 years
      If you don't want to transfer the whole contents of ~/path/ then you should look at rsync's --files-from option.
    • Nemoden
      Nemoden over 9 years
      @wurtel, this is actually the best decision addressing the problem so far. If you answer the question, I will accept.