特定の単語を含む行を印刷する[重複]

特定の単語を含む行を印刷する[重複]

file1.txt2つのファイル(&)があるとしましょうfile2.txt

file1.txt:(1行に1つずつ単語リストのみを含む)

Car
Ricky

file2.txt:(次の単語を使用する行(構文)を含みますfile1.txt。)

he has a Car
there is no food
I have a book
road is straight
Ricky is a good student

出力は次のようになります。

he has a Car
Ricky is a good student

ベストアンサー1

grepこのオプションをサポートする場合-w:

grep -wFf file1.txt file2.txt

おすすめ記事