Normally I'd do something like
Code:
(ls -1 firstdir;ls -1 seconddir)|sort|uniq -u
but this has the disadvantage that you can't tell in which directory the unique file(s) is(/are).
A bit of interactive python doesn't have this problem:
Code:
import os
# replace firstdir and seconddir with the paths to the directories in question
a=os.listdir('firstdir')
b=os.listdir('seconddir')
# this prints the files in firstdir that are not in seconddir
print([x for x in a if x not in b])
# the ones in seconddir but not in firstdir
print([x for x in b if x not in a])
Turning this into a script that gets arguments from sys.argv[] to use as firstdir and seconddir is left as an exercise to the reader.
Holger
Bookmarks