Softpanorama

Home Switchboard Unix Administration Red Hat TCP/IP Networks Neoliberalism Toxic Managers
May the source be with you, but remember the KISS principle ;-)
Skepticism and critical thinking is not panacea, but can help to understand the world better

Comparing directory trees with rsync

$ rsync -rvnc --delete website/ laptop:projects/website/
deleting schedule.shtml
style.css

ATTENTION: The -c option is used because we're paranoid: it forces rsync to compute and compare checksums for each file to verify that they are the same. Otherwise, rsync assumes that files are the same if they have the same timestamp and size (sometimes this gives false positives if timestamps were not preserved when you made the copy). If that is acceptable, you can omit -c to get a speedup.

Compare two folders(recursively) for file names and file contents

Dry run with the update switch (-u) meaning it will only overwrite changed files.

 

Code:
rsync -ruptvn src/ dst/ > /tmp/output
Then you can edit the output file and delete the "speedup" output from the top and bottom so you just have the files to work with. Then you can run a diff...

Assuming you're using bash with the following,
 
Code:
sourcedir=src;destdir=dst;cat /tmp/output | while read file;do diff -rupN $sourcedir/$file $destdir/$file;done >> /tmp/differences;unset sourcedir destdir
Look at the /tmp/differences file to see the changes from diff.

SAM