Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
file1 と file2 があります。file1 の行が file2 に存在するかどうかを検索して出力する必要があります。存在しない場合は、エントリが存在しないことを知る必要があります。Linuxコマンドでこれを達成するにはどうすればよいですか?
grepだけが必要です:
grep -f file1 file2
file1 を正規表現パターンではなく固定文字列として処理する場合は、パラメーター -F を追加する必要があります。
grep -F -f file1 file2
grep はこのタスクを実行できます。
grep -f File1 File2
ただしdiff、 や などの他のコマンドcmpも使用できます。
diff
cmp