Bash script to recursively traverse directories, compare and sync files
===

I'm trying to write a bash shell script to sync content on two different paths.

The algorithm I'm striving for consists of the following steps
1) given two full (as opposed to relative) paths
2) recursively compare files (whose filename optionally may have basename and suffix) in corresponding directories of both paths
3) if either corresponding directories or files are not present, then copy each file (from the path with the folder) to the other corresponding folder.

I've figured out steps 1 and 2 which are 

    OLD_IFS=$IFS
    # The extra space after is crucial
    IFS=\
    
    for old_file in `diff -rq old/ new/ | grep "^Files.*differ$" | sed 's/^Files \(.*\) and .* differ$/\1/'`
    do
       mv $old_file $old_file.old
    done
    IFS=$OLD_IFS

Thanks.