Наскільки я знаю, немає можливості сказати findчитати шаблони з файлу. Простий спосіб вирішити - зберегти шаблони, які я хочу виключити, і передати цей файл як вхід для зворотного grep. Як приклад, я створив такі файли та каталоги:
$ tree -a
.
├── a
├── .aa
├── .aa.bak
├── a.bck
├── b
├── .dir1
│ └── bb1.bak
├── dir2
│ └── bb2.bak
├── b.bak
├── c
├── c~
├── Documents
│ └── Documents.bak
├── exclude.txt
├── foo.backup
└── Music
└── Music.bak
Якщо я зрозумів приклад ви розміщені правильно, ви хочете перемістити a.bck, .aa.bak, b.bak, c~, foo.backupі dir2/bb2.bakв смітник і відпустки .aa.bak, .dir1/bb1.bak, Documents/Documents.bakі Music/Music.bakде вони знаходяться. Тому я створив файл exclude.txtіз таким вмістом (ви можете додати скільки завгодно):
$ cat exclude.txt
./.*/
./Music
./Documents
Я використовую, ./.*/тому що я зрозумів, що ваша оригінальна знахідка означає, що ви хочете перемістити приховані файли резервної копії ( .foo), які знаходяться в поточному каталозі, але виключають будь-які файли резервного копіювання, які знаходяться в прихованих каталогах ( .foo/bar). Отже, тепер я можу запустити findкоманду та використовувати grepдля виключення непотрібних файлів:
$ find . -type f | grep -vZf exclude.txt | xargs -0 --no-run-if-empty trash-put
Варіанти перемикання:
-v, --invert-match
Invert the sense of matching, to select non-matching
lines. (-v is specified by POSIX.)
-f FILE, --file=FILE
Obtain patterns from FILE, one per line. The empty
file contains zero patterns, and therefore matches
nothing. (-f is specified by POSIX.)
-Z, --null
Output a zero byte (the ASCII NUL character) instead of
the character that normally follows a file name. For
example, grep -lZ outputs a zero byte after each file
name instead of the usual newline. This option makes
the output unambiguous, even in the presence of file
names containing unusual characters like newlines.
This option can be used with commands like find
-print0, perl -0, sort -z, and xargs -0 to process
arbitrary file names, even those that contain newline
characters.