未包含在另一个文件从一个文件打印行 [英] Print lines from one file that are not contained in another file
本文介绍了未包含在另一个文件从一个文件打印行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我要打印在一个文件中,但不是在另一个文件中的行。然而,无论是文件排序,我需要保留这两个文件的原始顺序。
文件1的内容:
字符串2
字符串1
STRING3 file2的内容:
STRING3
字符串1 输出:
字符串2
有一个简单的脚本,我可以做到这一点?
解决方案
比fgrep -x -f文件2 -v文件1
-x匹配整行
-f文件从文件中获取的模式
-v反转的结果(显示不匹配)
I wish to print lines that are in one file but not in another file. However, neither files are sorted, and I need to retain the original order in both files.
contents of file1:
string2
string1
string3
contents of file2:
string3
string1
Output:
string2
Is there a simple script that I can accomplish this in?
解决方案
fgrep -x -f file2 -v file1
-x match whole line
-f FILE takes patterns from FILE
-v inverts results (show non-matching)
这篇关于未包含在另一个文件从一个文件打印行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文