您现在的位置是:网站首页> 编程资料编程资料
linux 比较两个文件夹diff不同 (diff命令, md5列表)_linux shell_
2023-05-26
437人已围观
简介 linux 比较两个文件夹diff不同 (diff命令, md5列表)_linux shell_
比较文件夹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压缩会带上文件的时间

总结
以上所述是小编给大家介绍的linux 比较两个文件夹diff不同 (diff命令, md5列表),希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对网站的支持!
相关内容
- Linux下快速比较两个目录的不同(多种方法)_linux shell_
- Linux 删除文件夹和文件的命令(强制删除包括非空文件)_linux shell_
- Vim 编辑器操作汇总_linux shell_
- Shell中关于时间和日期的函数总结_linux shell_
- Linux启动jar包的shell脚本_linux shell_
- linux设置定时任务的方法步骤_linux shell_
- Linux常用ls, alias基础命令详解_linux shell_
- Linux 实现压缩保留源文件的方法_linux shell_
- shell脚本实现服务器进程监控的方法_linux shell_
- Linux下/var/run/目录下的pid文件详解及pid文件作用_linux shell_
