[root@localhost python]
import filecmp
path1="/root/python/a"
path2="/root/python/b"
test=filecmp.dircmp(path1,path2)
print 'all files and dirs in left_list(path1): '+str(test.left_list)
print "common files"+str(test.common_files)
print "diff files"+str(test.diff_files)
print "common dirs"+str(test.common_dirs)
print "common dirs and files"+str(test.common)
print "only in left list,no in right list: "+str(test.left_only)
print "same_files is: "+str(test.same_files)
[root@localhost python]
all files and dirs in left_list(path1): ['a.txt', 'b.txt', 'info.py', 'k', 'k.py', 'kali', 'linux']
common files['kali', 'a.txt', 'info.py']
diff files['a.txt']
common dirs['k']
common dirs and files['kali', 'a.txt', 'info.py', 'k']
only in left list,no in right list: ['b.txt', 'k.py', 'linux']
same_files is: ['kali', 'info.py']
[root@localhost python]
a:
a.txt b.txt info.py k kali k.py linux
a/k:
c.txt
b:
a.txt bp c.txt info.py k kali
b/k:
k.py linux
[root@localhost python]
linux
ok
[root@localhost python]
a
a
[root@localhost python]