I wanted to get 16 bytes from a binary file, starting from 5th byte, no separation of bytes or words by spaces.
hexdump will do what I want, just the offset column is disturbing the output:
$ hexdump -s5 -n16 -xe '/1 "%01X"' binfile
od does the task fine as well and can even be told to suppress the offset column, although I had to use
sed to get rid of the spacing:
$ od -An -tx1 -j5 -N16 | sed 's/ //g' binfile
I am sure it will work without
sed, but as I had many issues with
od in hex mode related to endianness (swapped bytes), this is not as easy as it looks.
For instance, changing
-tx1 to anything higher will swap the bytes and mess up the 128-bit value that I want.
-tx1 is fine, but unlike
hexdump I haven't found a way to get rid of the spaces while keeping byte order as-is at the same time.