linux比较两个文件md5,linux 比较两个文件夹diff不同 (diff命令, md5列表)

本文介绍了如何在Linux系统中使用`diff`命令比较两个文件夹的差异,以及通过`md5sum`获取文件夹中文件的MD5列表。还提到了在比较文件时,需要注意tar压缩会影响MD5校验结果。
摘要由CSDN通过智能技术生成

linux 比较两个文件夹diff不同 (diff命令, md5列表)

比较文件夹diff,可以直接使用diff命令

[root@~]# diff -urNa dir1 dir2

-a Treat all files as text and compare them line-by-line, even if they do not seem to be text.

-N, --new-file

In directory comparison, if a file is found in only one directory, treat it as present but empty in the other directory.

-r When comparing directories, recursively compare any subdirectories found.

-u Use the unified output format.

比较文件夹diff,也可以比较文件MD5列表。下面命令可以获取文件夹中文件md5列表

find /home/ -type f -not \( -name '.*' \) -exec md5sum {} \;

说明:

(1) /home/文件目录

(2) -type f 文件类型为普通文件

(3) -not \( -name '.*' \)  过滤掉隐藏文件。可以过滤掉不需要考虑的文件

(4) -exec md5sum {} \;  对每个文件执行md5sum命令

用tar命令压缩后,比较文件的MD5是不行的。tar压缩会带上文件的时间

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值