Я часто использую grep
для подобных вещей. В этом случае я бы использовал
Отредактировано для добавления расширений файлов:
grep -l string1 *.txt > string1_files.txt && grep -l string2 *.txt> string2_files.txt
Этот oneliner будет искать string1
в txt
файлах в текущем каталоге, запись вывода в string1_files.txt
и аналогично для string2
копирование из man grep
-l, --files-with-matches
Only the names of files containing selected lines are written to
standard output. grep will only search a file until a match has
been found, making searches potentially less expensive. Path-
names are listed once per file searched. If the standard input
is searched, the string ``(standard input)'' is written.
Надеюсь, это немного поможет, но вам может потребоваться выполнить поиск только определенных расширений файлов
Редактировать без расширений файлов: (если они недоступны, как в комментариях к вопросу
grep -l string1 * > string1_files.txt && grep -l string2 *> string2_files.txt