0

It is inconceivable that this is proving to be so difficult but I'm trying to use rsync to copy only files matching a specific pattern. Specifically, copy files in all subdirectories matching "*000.csv"

You would think that the following

rsync -avrP --include='*000.csv' host:'~/data/' .

would do the trick. Instead this targets all files in all subdirectories (?!). This blog suggests you can only "include" things that have been excluded first. Okay, so then why do these:

rsync -avrP --exclude='*' --include='*000.csv' host:'~/data/' .

rsync -avrP --filter='-! */' --include='*000.csv' host:'~/data/' .

both target no files at all. Please help. Thank you.

  • 1
    try **/*000.csv or **000.csv. * matches anything except slashes, ** matches anything including slashes. see man rsync and search for "PATTERN RULES". – cas Feb 03 '18 at 02:47

1 Answers1

2

From your code, it looks like you are trying to copy from the remote host to your local machine. With that being said:

rsync -avP --include='*000.csv' --exclude='*.*' user@host:~/data ./

You don't need r as the a option implies r.

Chris Davies
  • 116,213
  • 16
  • 160
  • 287
Nasir Riley
  • 11,422