diff目录,其中不包含一个文件夹


44

我想我有两个目录具有相同的内容,但我想检查一下。

另外,我想排除两个目录中的文件夹。

我该怎么做?

Answers:


48

命令行:

diff --exclude=direxclude -r dir1 dir2

openSUSE 12.1:好的。

sttr@linux-sgfb:/tmp> md dir1
sttr@linux-sgfb:/tmp> md dir2
sttr@linux-sgfb:/tmp> cd dir2
sttr@linux-sgfb:/tmp/dir2> md 10
sttr@linux-sgfb:/tmp/dir2> md 11
sttr@linux-sgfb:/tmp/dir2> md 12
sttr@linux-sgfb:/tmp/dir2> md 14
sttr@linux-sgfb:/tmp/dir2> cd ..
sttr@linux-sgfb:/tmp> cd dir1
sttr@linux-sgfb:/tmp/dir1> md 15
sttr@linux-sgfb:/tmp/dir1> md 11
sttr@linux-sgfb:/tmp/dir1> md 12
sttr@linux-sgfb:/tmp/dir1> md 17
sttr@linux-sgfb:/tmp/dir1> cd ..
sttr@linux-sgfb:/tmp> diff --exclude="11" -r dir1 dir2
Only in dir2: 10
Only in dir2: 14
Only in dir1: 15
Only in dir1: 17
sttr@linux-sgfb:/tmp> diff --exclude=11 -r dir1 dir2
Only in dir2: 10
Only in dir2: 14
Only in dir1: 15
Only in dir1: 17
sttr@linux-sgfb:/tmp>

CentOS 6.3 64:好的。

[root@local tmp]# mkdir dir1
....

Ubuntu 12.04 TLS:好的。

Ubuntu 12.04 TLS


1
@STTR对不起,但没有成功
2013年

@ user35538​​您能否更具体些?什么不起作用,您输入了什么?
丹尼尔·贝克

1
diff --exclude="direxclude" -r dir1 dir2变体?
STTR

版本OS测试?
STTR

1
@STTR Ubuntu 12.04
user35538
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.