From 6df549d1234f6a50d79ce56a367addc8ec263a16 Mon Sep 17 00:00:00 2001 From: Jan Krautmacher Date: Thu, 25 Sep 2025 07:19:31 +0200 Subject: posix-shell: utils: Add hexdiff() This tool outputs the diff of two hexdumps based on the two files provided as arguments. --- posix-shell/utils.sh | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'posix-shell/utils.sh') diff --git a/posix-shell/utils.sh b/posix-shell/utils.sh index b1ffc21..f19602d 100644 --- a/posix-shell/utils.sh +++ b/posix-shell/utils.sh @@ -225,3 +225,21 @@ lar() { popd rm -rf "$temp" } + +hexdiff() { + if test "$#" -ne 2 + then + echo "Usage: hexdiff " + return 1 + fi + + dump1="$(mktemp)" + dump2="$(mktemp)" + + hexdump -C "$1" > "$dump1" + hexdump -C "$2" > "$dump2" + + diff --unified=4 --color=always "$dump1" "$dump2" + + rm -f "$dump1" "$dump2" +} -- cgit v1.2.3-70-g09d2