Q:

compare checksum of files between two remote servers

On my local box "machineA", I have two folders "/primary" and "/secondary".  These two folders have some files in it.  Now on the remote server "machineB" I have one folder "/bat/snap/" which contains lots of file.  
All the files in "/primary" and "/secondary" folders in "machineA" should be there in "machineB" remote server in this directory "/bat/snap/".  Now I need to compare checksum of all files in "/primary" and "/secondary" folder on local box "machineA" with remote server in this directory "/bat/snap/".  If there is any mismatch in checksum then I want to report all those files that have issues in "machineA". 
I wrote one command that I am running on machineA but it gives me an error:
find /primary/ /secondary/ -type f | xargs md5sum | ssh machineB '(cd /bat/snap/ && md5sum -c)' | egrep -v 'OK$'

Below is the error I am getting and after that I stopped my above command.  I checked both the servers and I can see this file is present so what's wrong then? 
md5sum: /primary/abc_monthly_134_proc_7.data: No such file or directory
/primary/abc_monthly_134_proc_7.data: FAILED open or read

A:

I think it has to do with multiple path from machineA included in the filename processed over in machineB... the following command isn't pretty but worked for me, hope it helps. 
find /primary/ /secondary/ -type f | xargs md5sum | awk -F'/' '{print "echo "$1 $NF " | ssh user@machineB \"(cd /bat/snap/  && md5sum -c)\""}' | bash

