This question is related to the answer from enzotib to the question: How could I use Bash to find 2 bytes in a binary file, increase their values, and replace?

This converts the two bytes into its hex value:

$ echo -n $'\x1b\x1f' | od -tx2
0000000 1f1b

But now, this should give me the decimal value:

echo -n $'\x1b\x1f' | od -tu2
0000000  7963

But if I convert the hex value into decimal it should be

$ printf "%d" 0x1b1f

Why is that? Am I using od wrong for decimal output?


You're running od on a little-endian machine.

>>> 0x1f1b

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.