linux 比较两个文件夹不同 (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.

比较文件夹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压缩会带上文件的时间

 

相关文章
|
9天前
|
NoSQL Linux Shell
常用的 Linux 命令
常用的 Linux 命令
32 9
|
2天前
|
安全 Linux 开发工具
Linux中可引起文件时间戳改变的相关命令
【4月更文挑战第12天】Linux中可引起文件时间戳改变的相关命令
9 0
|
3天前
|
域名解析 网络协议 Linux
Linux 中的 Nslookup 命令怎么使用?
【4月更文挑战第12天】
22 6
Linux 中的 Nslookup 命令怎么使用?
|
4天前
|
运维 网络协议 Unix
18.系统知识-Linux常用命令
18.系统知识-Linux常用命令
|
5天前
|
网络协议 Ubuntu Linux
Linux 下 TFTP 服务搭建及 U-Boot 中使用 tftp 命令实现文件下载
Linux 下 TFTP 服务搭建及 U-Boot 中使用 tftp 命令实现文件下载
|
5天前
|
Linux Go
Linux命令Top 100驱动人生! 面试必备
探索Linux命令不再迷茫!本文分10部分详解20个基础命令,带你由浅入深掌握文件、目录管理和文本处理。 [1]: <https://cloud.tencent.com/developer/article/2396114> [2]: <https://pan.quark.cn/s/865a0bbd5720> [3]: <https://yv4kfv1n3j.feishu.cn/docx/MRyxdaqz8ow5RjxyL1ucrvOYnnH>
49 0
|
8天前
|
缓存 运维 监控
Linux系统监控利器:探索常用命令及数据保存技巧
Linux系统监控利器:探索常用命令及数据保存技巧
27 4
Linux系统监控利器:探索常用命令及数据保存技巧