Different files of two directories
You're looking for
diff -rq (dir1) (dir2)
Proof of concept:
#!/bin/sh
#create our test
mkdir -p /tmp/a/b
echo "test" >> /tmp/a/c
mkdir -p /tmp/a/d/e
echo "blah" >> /tmp/a/d/e/f #only exists here
mkdir -p /tmp/q/b
echo "testing" >> /tmp/q/c #/tmp/a/c shouldnt match
mkdir -p /tmp/q/d/e
echo "blah" >> /tmp/q/d/e/g #only exists here
diff -rq /tmp/a /tmp/q
results in :
Files /tmp/a/c and /tmp/q/c differ
Only in /tmp/a/d/e: f
Only in /tmp/q/d/e: g
You just need to include the -q flag to make it brief:
# diff -q dir1 dir2
Files dir1/both and dir2/both differ
Only in dir1/: one
Only in dir2:/ two
For finding duplications, you one use:
fdupes -r1 dir1 dir2
Although the others gave you numerous good tips, you should give it it a try too.
If you use
fdupes -rd dir1 dir2
it will prompt you which file to keep (the others will be deleted). Extremely useful for removing duplications (I did make a good use of it with my photos)
NOTE: yes, I know the question wasn't exactly about this, but maybe it can help him or others ;)
If you want compare files based on e.g. size you can do:
# ls -al DIR_1 |awk '{print $5, $9}'|sort > 1.txt
# ls -al DIR_2 |awk '{print $5, $9}'|sort > 2.txt
and than:
# diff 1.txt 2.txt
to find out which files have different or are missing. I used this when I had to compare two directories with very large files to see which files are not fully downloaded.