diff options
author | Florian Pritz <bluewind@xinu.at> | 2018-08-08 10:27:38 +0200 |
---|---|---|
committer | Florian Pritz <bluewind@xinu.at> | 2018-08-08 10:27:38 +0200 |
commit | cf825a17e91337927fad2738e6816f02136a9c5f (patch) | |
tree | d52c86437487193bc8572a70085b5318c863b412 /bindiff | |
parent | 1529f1100e207bb865720471cc47d50b7c1ffc28 (diff) | |
download | bin-cf825a17e91337927fad2738e6816f02136a9c5f.tar.gz bin-cf825a17e91337927fad2738e6816f02136a9c5f.tar.xz |
bindiff: Output binary representation of file
Signed-off-by: Florian Pritz <bluewind@xinu.at>
Diffstat (limited to 'bindiff')
-rwxr-xr-x | bindiff | 17 |
1 files changed, 16 insertions, 1 deletions
@@ -6,4 +6,19 @@ if [[ $# != 2 ]]; then fi #sdiff -w 150 -Hs <(xxd -b "$1") <(xxd -b "$2") -cmp -l "$1" "$2" | awk '{printf "%08X %02X %02X\n", $1, strtonum(0$2), strtonum(0$3)}' + +cmp -l "$1" "$2" | awk 'function bits2str(bits, data, mask) +{ + if (bits == 0) + return "0" + + mask = 1 + for (; bits != 0; bits = rshift(bits, 1)) + data = (and(bits, mask) ? "1" : "0") data + + while ((length(data) % 8) != 0) + data = "0" data + + return data +} +{printf "%08X %s %s\n", $1, bits2str(strtonum(0$2)), bits2str(strtonum(0$3))}' |