Binary File Comparison Cheatsheet: Using diff, cmp, and xxd
Elevate your file comparison skills with our expert cheatsheet on binary file analysis using diff, cmp, and xxd.
Discover advanced commands for hex comparison, string differences, and visual diff tools, tailored for developers and IT professionals.
This will print the offset and bytes in hex
cmp -l file1.bin file2.bin | gawk '{printf "%08X %02X %02X\n", $1, strtonum(0$2), strtonum(0$3)}'
Or do $1-1 to have the first printed offset start at 0
cmp -l file1.bin file2.bin|gawk '{printf "%08X %02X %02X\n", $1-1, strtonum(0$2), strtonum(0$3)}'
diff + xxd
diff -y <(xxd foo1.bin) <(xxd foo2.bin)
colordiff + xxd
colordiff -y <(xxd foo1.bin) <(xxd foo2.bin)
Diff two files with diff + strings
diff -y <(strings device.cfg) <(strings device2.cfg)