本文介绍了如何获得在linux两个文件之间的差异(只添加)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有两个文件,A1和A2(未分类)。 A1是A2的previous版本和部分线路已被添加至A2。我怎样才能被添加到A2的新线路?
I have two files A1 and A2 (unsorted). A1 is previous version of A2 and some lines have been added to A2. How can I get the new lines that are added to A2?
请注意:我只是希望新的线路增加和不想要的是在A1但在A2删除线。当我做差异A1 A2
,我得到了增加,以及缺失,但我只想补充。
Note: I just want the new lines added and dont want the lines which were in A1 but deleted in A2. When i do diff A1 A2
, I get the additions as well as deletions but I want only additions.
请提出一个办法做到这一点。
Please suggest a way to do this.
推荐答案
差异
然后的grep
为编辑键入你想要的。
diff
and then grep
for the edit type you want.
diff -u A1 A2 | grep -E "^\+"
这篇关于如何获得在linux两个文件之间的差异(只添加)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!