使用grep从列表中选择与任何单词匹配的行

leg*_*o69 2 linux shell scripting csh tcsh

grep如果出现了单词列表中的至少一个元素,可以 选择行吗?例如

grep "hello world" file1 
Run Code Online (Sandbox Code Playgroud)

grep必须给我所有包含单词hello或单词world或两者都包含的行。

zed*_*xff 5

把你的模式放在一些文件 patterns.txt 中,每行一个模式,然后运行

grep -Ff patterns.txt file1
Run Code Online (Sandbox Code Playgroud)