0

I am trying to copy only the files that match the pattern player00_0[1..5]*.* where [1..5] signifies files with a 1,2,3,4, or 5 at that position in the filename. There are 40K files in the source dir so we can not use any bash globs for this job.

Here is my attempt to do that:

indir=playout40kem
outdir=visible5k
rsync -am --include='player00_01*.*' --include='player00_02*.*' 
          --include='player00_03*.*' --include='player00_04*.*' 
          --include='player00_05*.*' $indir/ $outdir

However the result is that all files are copied. What is the correct way to do this filtering?

1 Answers1

0

From https://unix.stackexchange.com/a/582184/66602 The missing piece is:

--exclude="*" . It must follow the include= entries:

rsync -am --include='player00_01*.*' --include='player00_02*.*' 
          --include='player00_03*.*' --include='player00_04*.*' 
          --include='player00_05*.*' --exclude="*" $indir/ $outdir
  • 1
    Character classes/range expressions are allowed in rsync patterns and please quote your variables, e.g. rsync -am --include='player00_0[1-5]*.*' --exclude="*" "$indir"/ "$outdir" – Freddy Dec 06 '20 at 23:52
  • @Freddy feel free to make an answer - in particular the use of class/range expressions – WestCoastProjects Dec 07 '20 at 01:05