且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何比较两个文本文件,使用BASH完全相同的文字?

更新时间:2023-11-30 20:31:46

假设顺序并不重要,

grep -F -f FILE2 FILE1

应该做的伎俩。 (这工作,因为一个鲜为人知的事实:在 -F 选项的grep 并不仅仅意味着比赛这种固定字符串,它意味着匹配任何这些换行符分隔固定字符串。)

should do the trick. (This works because of a little-known fact: the -F option to grep doesn't just mean "match this fixed string," it means "match any of these newline-separated fixed strings.")