diff文件只比较每行的前n个字符 [英] diff files comparing only first n characters of each line

查看:573
本文介绍了diff文件只比较每行的前n个字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有2个文件。让我们称它们为md5s1.txt和md5s2.txt。都包含

I have got 2 files. Let us call them md5s1.txt and md5s2.txt. Both contain the output of a

find -type f -print0 | xargs -0 md5sum | sort > md5s.txt

命令。许多文件已重命名,但内容保持不变。因此,它们应该具有相同的md5sum。我想生成一个像

command in different directories. Many files were renamed, but the content stayed the same. Hence, they should have the same md5sum. I want to generate a diff like

diff md5s1.txt md5s2.txt

但它应该只比较每行的前32个字符,即只有md5sum,而不是文件名。具有相等md5sum的线应当被视为相等。

but it should compare only the first 32 characters of each line, i.e. only the md5sum, not the filename. Lines with equal md5sum should be considered equal. The output should be in normal diff format.

推荐答案

简单起始:

diff <(cut -d' ' -f1 md5s1.txt)  <(cut -d' ' -f1 md5s2.txt)

此外,考虑

diff -EwburqN folder1/ folder2/

这篇关于diff文件只比较每行的前n个字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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