加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > Linux > 正文

如何比较目录之间的差异(linux)

发布时间:2020-12-13 18:34:27 所属栏目:Linux 来源:网络整理
导读:我有两个目录 – 一个来自早期备份,另一个来自最新备份.如何比较 Linux上最新备份对目录中文件所做的更改?另外我如何显示例如文本和php文件的变化 – 我正在考虑像维基百科上的修订历史,你在屏幕的一侧看到旧版本,在其他版本上看到最新版本,并突出显示更改.
我有两个目录 – 一个来自早期备份,另一个来自最新备份.如何比较 Linux上最新备份对目录中文件所做的更改?另外我如何显示例如文本和php文件的变化 – 我正在考虑像维基百科上的修订历史,你在屏幕的一侧看到旧版本,在其他版本上看到最新版本,并突出显示更改.我如何实现这样的目标?

编辑:
我如何比较远程目录与本地?

解决方法

来自diff手册页:

If both from-file and to-file are directories,diff compares corresponding files in both directories,
in alphabetical order; this comparison is not recursive unless the -r or –recursive option is given.
diff never compares the actual contents of a directory as if it were a file. The file that is fully
specified may not be standard input,because standard input is nameless and the notion of ‘‘file with
the same name’’ does not apply.

所以要比较目录:diff –brief -r dir1 dir2

并排比较文件:diff –side-by-side file1 file2

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读