Using rsync with patterns

4

How can I make copies of only the files whose names are similar to ones patterns ( patterns ) ? I tried using rsync , but either nothing is copied or everything is copied. These questions in SO in English did not help me:

  • rsync include-from problems
  • Using Rsync include and exclude options to include directory and file by pattern
  • Here are some of my attempts to do it:

    • Everything on the command line (command line):

      rsync -rv --include='solexa/' --include='solexa/*/*.csv' --exclude='*' solexa RunMetrics
      
    • With a pattern file:

      rsync -av --include-from patrones.txt solexa RunMetrics
      

      Here is my pattern file ( patterns ) when nothing is copied. I want to copy only the files with names that start with a number:

      + ^\d.*/*.csv
      - *
      

      Here is my file of " patterns " when you copy everything:

      + */*.csv
      

    I do not care if it's done with rsync or with another tool, I just thought that rsync had the capabilities to do it.

        
    asked by Christopher Bottoms 09.12.2015 в 02:55
    source

    2 answers

    2
    • It seems that \d is not used in this type of pattern, but the patr: on [0-9] corresponds well to the numbers (as used in bash ).
    • Also, you have to include patterns for all the directories above the files required (and you still have to include / at the end of the directory pattern):

    These patterns work to correspond to the desired files:

    + [0-9].*/
    + [0-9].*/*.csv
    - *
    
        
    answered by 09.12.2015 в 04:07
    0

    And generating previously a file with the content of everything you want ...

    Something like this:

    $ find . -iname "[0-9]*" -exec echo "fichero " {} >> /tmp/lista_ficheros \;
    

    Then you can include / use it in the rsync using the - files-from

    parameter
    $ rsync ....  --files-from=/tmp/lista_ficheros** ....
    
        
    answered by 30.11.2017 в 13:19