compare checksum of files between two remote servers
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
Database Design For reporting comparison results
I would say neither of your two options (additional column, or new table) are optimal. I think this would be best handled with a view. Something like:
CREATE VIEW MisMatches
AS
SELECT Material_ID = ISNULL(a.Material_ID, b.Material_ID),
Status = CASE WHEN a.Material_ID IS NULL THEN 'Mising A'
WHEN b.Material_ID IS NULL THEN 'Mising B'
WHEN a.Material_Name <> b.Material_Name THEN 'Mismatch Name'
WHEN a.Material_Type <> b.Material_Type THEN 'Mismatch Type'
WHEN a.Quantity <> b.Quantity THEN 'Mismatch Quantity'
END,
MaterialName_A = a.Material_Name,
MaterialName_B = b.Material_Name,
Material_Type_A = a.Material_Type,
Material_Type_B = b.Material_Type,
Quantity_A = a.Quantity,
Quantity_B = b.Quantity
FROM A_Data AS a
FULL JOIN B_Data AS b
ON b.Material_ID = a.Material_ID
WHERE CHECKSUM(a.Material_Name, a.Material_Type, a.Quantity) <> CHECKSUM(b.Material_Name, b.Material_Type, b.Quantity);
This short circuits on your status column which may not be what you want, that is to say that if you name, quantity and type all don't match, then the status will only tell you that the name is a mismatch. If you want all mis-matches you will need to extend the case expression slightly. Also, if any of your columns are nullable, you will need to handle this in the Status
case expression, e.g.
WHEN a.Quantity <> b.Quantity OR a.Quantity IS NULL OR b.Quantity IS NULL THEN ...
I have also had to make an assumption about how you identify a match, but hopefully this gives the general gist of it
Edit
There is a better way of doing this rather than CHECKSUM
:
CREATE VIEW MisMatches
AS
SELECT Material_ID = ISNULL(a.Material_ID, b.Material_ID),
Status = CASE WHEN a.Material_ID IS NULL THEN 'Mising A'
WHEN b.Material_ID IS NULL THEN 'Mising B'
WHEN a.Material_Name <> b.Material_Name THEN 'Mismatch Name'
WHEN a.Material_Type <> b.Material_Type THEN 'Mismatch Type'
WHEN a.Quantity <> b.Quantity THEN 'Mismatch Quantity'
END,
MaterialName_A = a.Material_Name,
MaterialName_B = b.Material_Name,
Material_Type_A = a.Material_Type,
Material_Type_B = b.Material_Type,
Quantity_A = a.Quantity,
Quantity_B = b.Quantity
FROM A_Data AS a
FULL JOIN B_Data AS b
ON b.Material_ID = a.Material_ID
WHERE NOT EXISTS
( SELECT a.Material_Name, a.Material_Type, a.Quantity
INTERSECT
SELECT b.Material_Name, b.Material_Type, b.Quantity
);
I discovered this read the following article: Undocumented Query Plans: Equality Comparisons
How to compare binary files to check if they are the same?
The standard unix diff
will show if the files are the same or not:
[me@host ~]$ diff 1.bin 2.bin
Binary files 1.bin and 2.bin differ
If there is no output from the command, it means that the files have no differences.
Related Topics
Cargo Plugin Throws Cargoexception When Deploying on Glassfish - Deployment Has Failed: Null
Awk, Pipe and Tail -F Giving Unexpected Behavior
How to Programatically Change an Executable Name (Ucmd) of a Unix Process
Force Netcat to Send Messages Immediately (Without Buffering)
What Register State Is Saved on a Context Switch in Linux
Scp Command Between 2 Servers with 2 Different .Pem Keys
Install Gdal on Python 2.7 on a Amazon Linux Virtual Server
X86 Assembly, Little Endianness Not Being Followed(Or Is It) (Linux)
Problems Building Libcurl 7.21.2 on Ubuntu 11.10 (Hiphop)
Linux Stand Alone Executable Generation
Shell Script to Check Ubuntu Version and Then Copy Files
Unix Unzip: How to Batch Unzip Zip Files in a Folder and Save in Subfolders
Intel Fortran Composer 2011 and Linux Mint 12
Firefox Not Closing After Selenium Tests Are Run
Making Strlcpy Available in Linux
How to Write a Bash Script That Cuts Images into Pieces Using Image Magick