您可以使用grep -f
:
grep -Ff "first-file" "second-file"
否则匹配完整的单词:
grep -w -Ff "first-file" "second-file"
根据评论:
awk 'FNR==NR{a[$1]; next} ($1 in a){delete a[$1]; print $1}' file1 file2
如何从一个文件找到另一个文件中的单词?
您可以使用grep -f
:
grep -Ff "first-file" "second-file"
否则匹配完整的单词:
grep -w -Ff "first-file" "second-file"
根据评论:
awk 'FNR==NR{a[$1]; next} ($1 in a){delete a[$1]; print $1}' file1 file2