Last active
September 18, 2022 13:27
-
-
Save dreamcat4/5bd545cde00f548f0774b5e88718fa78 to your computer and use it in GitHub Desktop.
Hex binary diff 2 files, with your own choice / variety of preferred diff tools
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# source discussion, over on superuser: | |
# https://superuser.com/questions/125376/how-do-i-compare-binary-files-in-linux | |
hex-binary-diff() | |
{ | |
_diffcmd="$1" | |
shift | |
unset _diff_opts | |
_arg="$1" | |
while [ "$_arg" ]; do | |
if [ "${_arg#-}" != "$_arg" ]; then | |
_diff_opts="$_diff_opts $_arg" | |
shift | |
_arg="$1" | |
else | |
break | |
fi | |
done | |
if [ ! "$2" ]; then | |
echo "usage: hex-binary-diff [--diff-options-flags|-opts] file1.bin file2.bin" | |
else | |
$_diffcmd $_diff_opts <(xxd "$1") <(xxd "$2") | |
fi | |
} | |
# for colordiff tool | |
alias hex-binary-colordiff="hex-binary-diff colordiff -W150 -y" | |
alias hex-binary-colordiff-compact="hex-binary-colordiff --suppress-common-lines" | |
# for meld gui diff tool | |
alias hex-binary-diff-meld="hex-binary-diff meld" | |
# for beyond compare diff tool | |
alias hex-binary-diff-meld="hex-binary-diff bcompare" | |
# other available tools which include a built-in binary diff functionality | |
alias hex-binary-diff-dhex="dhex" | |
alias hex-binary-diff-binwalk="binwalk -W" | |
# tools that let you directly EDIT the binary files (instead of just only view them) | |
alias hex-binary-diff-vbindiff="vbindiff" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment