a self note about hexa dumps:
default formatting, with address prefix:
$ hexdump .git/objects/b6/fc4c620b67d95f953a5c1c1230aaab5db5a1b0
0000000 78 01 4b ca c9 4f 52 30 65 c8 48 cd c9 c9 07 00
0000010 19 aa 04 09
0000014
dumping in \x00\x01\x02 format in 1 line:
hx() { hexdump -ve '"\\" "x" 1/1 "%02x"'; }
can be used for echo encode binary data:
bin=$(hx < .git/objects/b6/fc4c620b67d95f953a5c1c1230aaab5db5a1b0)
echo -e "$bin"
It can produce octal, decimal, hexa, and ASCII dump
od -An -t x1 < .git/objects/b6/fc4c620b67d95f953a5c1c1230aaab5db5a1b0
- -An : no address
- -t x1: type: 1 byte as hexa
Similar to hexdump, but has an -i/--include option to create c include file style
Which is almost golang byte slice comatible ...
$ xxd -i .git/objects/b6/fc4c620b67d95f953a5c1c1230aaab5db5a1b0
unsigned char _git_objects_b6_fc4c620b67d95f953a5c1c1230aaab5db5a1b0[] = {
0x78, 0x01, 0x4b, 0xca, 0xc9, 0x4f, 0x52, 0x30, 0x65, 0xc8, 0x48, 0xcd,
0xc9, 0xc9, 0x07, 0x00, 0x19, 0xaa, 0x04, 0x09
};
unsigned int _git_objects_b6_fc4c620b67d95f953a5c1c1230aaab5db5a1b0_len = 20;