Jika pohon direktori lebih dari sekedar ..../f03Anda dapat menggunakan rsyncperintah ini untuk menyalin setiap fo1& fo2dan mengecualikan setiap direktori lain dengan nama fo*.
$ rsync -avz --include='fo[12]/' --exclude='fo*/' \
Main_Dir/ new_Main_Dir/.
Ketika berhadapan dengan jenis-jenis skenario penyalinan ini, saya selalu menggunakan rsyncdan ini --dry-run& --verboseberalih sehingga saya bisa melihat apa yang akan dilakukan tanpa benar-benar harus menyalin file.
$ rsync -avz --dry-run --verbose --include='fo[12]/' --exclude='fo*/' \
Main_Dir/ new_Main_Dir/.
Contoh
Lari kering.
$ rsync -avz --dry-run --include='fo[12]/' --exclude='fo*/' \
Main_Dir/ new_Main_Dir/.
sending incremental file list
./
Subdir1/
Subdir1/fo1/
Subdir1/fo2/
Subdir2/
Subdir2/fo1/
Subdir2/fo2/
Subdir3/
Subdir3/fo1/
Subdir3/fo2/
sent 201 bytes received 51 bytes 504.00 bytes/sec
total size is 0 speedup is 0.00 (DRY RUN)
Jika Anda ingin melihat beberapa rsynclogika internal tentang apa yang dimasukkan / dikecualikan, gunakan --verbosesaklar.
$ rsync -avz --dry-run --verbose --include='fo[12]/' --exclude='fo*/' \
Main_Dir/ new_Main_Dir/.
sending incremental file list
[sender] showing directory Subdir1/fo2 because of pattern fo[12]/
[sender] showing directory Subdir1/fo1 because of pattern fo[12]/
[sender] hiding directory Subdir1/fo3 because of pattern fo*/
[sender] showing directory Subdir2/fo2 because of pattern fo[12]/
[sender] showing directory Subdir2/fo1 because of pattern fo[12]/
[sender] hiding directory Subdir2/fo3 because of pattern fo*/
[sender] showing directory Subdir3/fo2 because of pattern fo[12]/
[sender] showing directory Subdir3/fo1 because of pattern fo[12]/
[sender] hiding directory Subdir3/fo3 because of pattern fo*/
delta-transmission disabled for local transfer or --whole-file
./
Subdir1/
Subdir1/fo1/
Subdir1/fo2/
Subdir2/
Subdir2/fo1/
Subdir2/fo2/
Subdir3/
Subdir3/fo1/
Subdir3/fo2/
total: matches=0 hash_hits=0 false_alarms=0 data=0
sent 201 bytes received 51 bytes 504.00 bytes/sec
total size is 0 speedup is 0.00 (DRY RUN)
Jika Anda perlu mengecualikan bentuk direktori lain, Anda dapat menambahkan beberapa pengecualian.