There are two directories I'd like to compare. I tried diff but it includes the changes inside the files. All I want is something like this
file a is just in /A
file b is missing in /A
file c changed
directory d is missing in /A
directory e is just in /A
I think this is common when doing full file patching but I don't know a good solution.
You're looking for
Proof of concept:
results in :
You just need to include the -q flag to make it brief:
For finding duplications, you one use:
Although the others gave you numerous good tips, you should give it it a try too.
If you use
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:
and than:
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.
You could try a diff of
ls
:Not a single command but it should work.
The classic answer is the 'dircmp' command. It has its warts (piping the output through 'pr' to paginate it, for example), but if would give you a list of objects only in directory one or directory two, and then for the common files, it report 'same' or 'different' (and the file type for non-files - directories, etc).
The 'diff -rq' looks equivalent or better than the output from 'dircmp'.
I asked a somewhat similar question on Stack Overflow, and the answers I got may be of interest to you. I was particularly interested in finding missing files when comparing two directories.
I also specified that the solution should deal with renamed files (e.g. if file A which was in directory 1 is also present in directory 2 but has been renamed, the script should be aware of that).
The answer I chose (it's at the top) is quite useful. It might be worth a look as a starting point for your script.