测试准备:

snippet.bash
[yz@test ~]$ sudo yum install tree
 
[yz@test-2 ~]$ ll da/
-rw-rw-r-- 1 yz yz 3 Jan  9 08:53 f1.txt
-rw-rw-r-- 1 yz yz 3 Jan  9 08:53 f2.txt
[yz@test-2 ~]$ ll db/
-rw-rw-r-- 1 yz yz 3 Jan  9 08:53 f1.txt
-rw-rw-r-- 1 yz yz 3 Jan  9 08:54 f2.txt
-rw-rw-r-- 1 yz yz 3 Jan  9 08:54 f3.txt

列出目录结构

snippet.bash
[yz@test ~]$ tree da/ db/
da/
├── f1.txt
└── f2.txt
db/
├── f1.txt
├── f2.txt
└── f3.txt
 
0 directories, 5 files

使用diff比较整个目录

snippet.bash
[yz@test ~]$ diff -r da/ db/
diff -r da/f1.txt db/f1.txt
1c1
< A1
---
> B1
diff -r da/f2.txt db/f2.txt
1c1
< A2
---
> B2
Only in db/: f3.txt

使用diff和tree结合使用

snippet.bash
[yz@test ~]$ diff <(tree -Ci --noreport da/) <(tree -Ci --noreport db/)
1c1
< da/
---
> db/
3a4
> f3.txt

vimdiff图形化显示

snippet.bash
[yz@test ~]$ vimdiff <(cd da/; find . | sort) <(cd db/; find . | sort)

image-20210109090328715

参考