文件的差异,从第N行 [英] Difference of files from Nth line

查看:83
本文介绍了文件的差异,从第N行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想获得的两个文本文件的差异。然而,第一行可以随时改变。出于这个原因,我是从一个python执行此:

I am trying to get the difference of two text files. However, the first line can always change. For this reason I was executing this from a python:

tail -n +2 file1
tail -n +2 file2

然后我比较的结果从输出相匹配。

Then to compare I match the results from the outputs.

不过,我想用 AWK SED 如果可能的话。

However, I would like to use awk or sed if possible.

我发现迄今:

awk 'NR == FNR { A[$0]=3; next } !A[$0]' file2 file1

但这从第一行相比较。

but this compares from the first line.

我怎样才能从第二个差异比较行?

How can I diff from the second line?

推荐答案

您可以使用差异进程替换:

diff <(tail -n +2 file1) <(tail -n +2 file2)

这篇关于文件的差异,从第N行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆