Saturday, November 8, 2014

Check if 2 binary files are exactly the same in linux


By comparing the md5sum of two files you can tell if those files have the exact same content or not.

Let's make a quick script:

1
2
3
4
5
#!/bin/bash
md5sum $1 | cut -d' ' -f 1 > /tmp/j
md5sum $2 | cut -d' ' -f 1 > /tmp/k
 
diff -y /tmp/j /tmp/k

#!/bin/bash
md5sum $1 | cut -d' ' -f 1 > /tmp/j
md5sum $2 | cut -d' ' -f 1 > /tmp/k

diff -y /tmp/j /tmp/k

And then we can call it like this diffScript.sh bin1 bin2, where bin1 and bin2 are two files that we want to compare.

No comments:

Post a Comment