How to compare files with same names in two different directories using a shell script How to compare files with same names in two different directories using a shell script shell shell

How to compare files with same names in two different directories using a shell script


The diff command has a -r option to recursively compare directories:

diff -r /develop /main


diff -rqu /develop /main

It will only give you a summary of changes that way :)

If you want to see only new/missing files

diff -rqu /develop /main | grep "^Only

If you want to get them bare:

diff -rqu /develop /main | sed -rn "/^Only/s/^Only in (.+?): /\1/p"


The diff I have available allows recursive differences:

diff -r main develop

But with a shell script:

( cd main ; find . -type f -exec diff {} ../develop/{} ';' )