庆典:比较两个文件中的行 [英] bash: compare lines of two files
本文介绍了庆典:比较两个文件中的行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有包含单词的唯一排序列表两个文本文件:
文件1:
A
b
C
ð
文件2:
B
C
我需要仅包含在文件1中的多余的行的新的文件,因此,其结果将是
A
ð
解决方案
这是什么 COMM
是:
通讯 - 选择或拒绝公共行两个文件
块引用>您想
COMM -23文件1,2文件
这将燮的线preSS只输出文件2 的和的线在这两个文件的,留在文件1只的行。
更多答案这里格雷格Wooledge的wikiI have two text files that contain a unique sorted list of words:
File 1:
a b c d
File 2:
b c
I need a new file that contains only the extraneous lines in File 1, so the result will be
a d
解决方案This is what
comm
is for:comm -- select or reject lines common to two files
You want
comm -23 "File 1" "File 2"
which will suppress output of lines only in file 2 and lines in both files, leaving only lines in file 1. More answers here on Greg Wooledge's wiki
这篇关于庆典:比较两个文件中的行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文