как синхронизировать каталоги и файлы из источника в место назначения

Puede usar varios patrones en su comando grep, por ejemplo, para grep ambas líneas con 'ip' y 'ID de conexión':

tail -f logfile | grep -E 'ip|connection ID' --line-buffered 
-2
18.06.2018, 12:48
2 ответа

Вы можете использовать функцию фильтра rsync. Например, используйте следующую команду:

rsync -uva --filter="- *.odb" --filter="- *.a3db" /source-path/ /destination-path/
1
28.04.2021, 23:45

Используйте несколько шаблонов исключения:

rsync -av --exclude='*.odb' --exclude='*.a3db' source/ target/

Пример:

$ ls source
file-1.a3db  file-2.odb   file-4.a3db  file-5.odb   file-7.a3db  file-8.odb
file-1.c     file-2.txt   file-4.c     file-5.txt   file-7.c     file-8.txt
file-1.odb   file-3.a3db  file-4.odb   file-6.a3db  file-7.odb   file-9.a3db
file-1.txt   file-3.c     file-4.txt   file-6.c     file-7.txt   file-9.c
file-2.a3db  file-3.odb   file-5.a3db  file-6.odb   file-8.a3db  file-9.odb
file-2.c     file-3.txt   file-5.c     file-6.txt   file-8.c     file-9.txt

Используя -vдважды, мы получаем указание на то, что включено и что исключено:

$ rsync -avv --exclude='*.odb' --exclude='*.a3db' source/ target/
sending incremental file list
[sender] hiding file file-1.odb because of pattern *.odb
[sender] hiding file file-1.a3db because of pattern *.a3db
[sender] hiding file file-2.odb because of pattern *.odb
[sender] hiding file file-2.a3db because of pattern *.a3db
[sender] hiding file file-3.odb because of pattern *.odb
[sender] hiding file file-3.a3db because of pattern *.a3db
[sender] hiding file file-4.odb because of pattern *.odb
[sender] hiding file file-4.a3db because of pattern *.a3db
[sender] hiding file file-5.odb because of pattern *.odb
[sender] hiding file file-5.a3db because of pattern *.a3db
[sender] hiding file file-6.odb because of pattern *.odb
[sender] hiding file file-6.a3db because of pattern *.a3db
[sender] hiding file file-7.odb because of pattern *.odb
[sender] hiding file file-7.a3db because of pattern *.a3db
[sender] hiding file file-8.odb because of pattern *.odb
[sender] hiding file file-8.a3db because of pattern *.a3db
[sender] hiding file file-9.odb because of pattern *.odb
[sender] hiding file file-9.a3db because of pattern *.a3db
delta-transmission disabled for local transfer or --whole-file

(остальная часть выходного отрезка)

$ ls target
file-1.c   file-2.txt file-4.c   file-5.txt file-7.c   file-8.txt
file-1.txt file-3.c   file-4.txt file-6.c   file-7.txt file-9.c
file-2.c   file-3.txt file-5.c   file-6.txt file-8.c   file-9.txt

Это также работает, даже если файлы расположены в подкаталогах в source.

1
28.04.2021, 23:45

Теги

Похожие вопросы