比较两个目录中的文件 diff -rq

[root@bass test]# mkdir A B
[root@bass test]# tree A
A
└── lin

0 directories, 1 file
[root@bass test]# tree B
B
└── lin

0 directories, 1 file
[root@bass test]# echo "hello A" > A/lin 
[root@bass test]# echo "hello B" > B/lin 
[root@bass test]# diff -rq A B
Files A/lin and B/lin differ
[root@bass test]# echo "hello A" > B/lin 
[root@bass test]# diff -rq A B
[root@bass test]# 
[root@bass test]# mkdir A/a
[root@bass test]# mkdir B/b
[root@bass test]# diff -rql A B
Only in A: a
Only in B: b
Files A/lin and B/lin differ
[root@bass test]# diff -rql A B
Only in A: a
Only in B: b
Files A/lin and B/lin differ
[root@bass test]# ls
A  B
[root@bass test]# mv A/a/ A/x
[root@bass test]# tree A
A
├── lin
└── x

1 directory, 1 file
[root@bass test]# mv B/b B/x
[root@bass test]# tree B
B
├── lin
└── x

1 directory, 1 file
[root@bass test]# diff -rq A B
Files A/lin and B/lin differ
[root@bass test]# cat A/lin 
hello A
[root@bass test]# cat B/lin 
hello B

 

 

[root@bass test]# touch A/x/chen
[root@bass test]# touch B/x/chen
[root@bass test]# diff -rq A B
Files A/lin and B/lin differ
[root@bass test]# echo "hello chen" > A/x/chen 
[root@bass test]# echo "hello chen" > B/x/lin 
[root@bass test]# diff -rq A B
Files A/lin and B/lin differ
Files A/x/chen and B/x/chen differ
Only in B/x: lin

 

posted @ 2016-06-03 11:07  bass  阅读(530)  评论(0编辑  收藏  举报