1

If I want to sync txt files in every Test 3 directory only, how would I do that if the directory structure is:

/mnt/this/Test 3/dir/file1.txt
/mnt/Test 3/dir/file01.txt
/mnt/Test/Test 3/file2.txt
/mnt/that/Test 3/dir/file03.txt
/mnt/the other/stuff/good/Test 3/file-1.txt

I've tried:

rsync -rv --include 'Test 3/' --include '*.txt' --exclude '*' --exclude '/*' . /mnt/backup/Test\ 3/
rsync -rv --include '*/Test 3' --include '*.txt' --exclude '*' . /mnt/backup/Test\ 3/
rsync -rv --include '*Test 3*' --include '*.txt' --exclude '*' . /mnt/backup/Test\ 3/

None of which works of course.

Gilles 'SO- stop being evil'
  • 807,993
  • 194
  • 1,674
  • 2,175
Rob Campbell
  • 31
  • 1
  • 2
  • 1
    Do you want to copy files under `…/Test 3` that aren't called `*.txt`? Do you want to copy empty `Test 3` directories? Should `somewhere/Test 3/foo.txt` and `elsewhere/Test 3/foo.txt` both map to `/mnt/backup/Test 3/foo.txt` or should they map to `/mnt/backup/Test 3/somewhere/Test 3/foo.txt` and `/mnt/backup/Test 3/eksewhere/Test 3/foo.txt` respectively? – Gilles 'SO- stop being evil' Sep 18 '20 at 23:16
  • I want to get every .txt file in all subdirs – Rob Campbell Nov 15 '20 at 13:51
  • So what's the significance of `Test 3` then? And do you want to put them all in the same place, or do you want to reproduce the directory structure? – Gilles 'SO- stop being evil' Nov 15 '20 at 15:58
  • Depending on what you want to do, https://unix.stackexchange.com/questions/2161/rsync-filter-copying-one-pattern-only may or may not answer your question. – Gilles 'SO- stop being evil' Nov 15 '20 at 15:58

0 Answers0