0

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
0000002

But now, this should give me the decimal value:

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

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

$ printf "%d" 0x1b1f
6943

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

erik
  • 16,959
  • 4
  • 32
  • 46

1 Answers1

4

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

>>> 0x1f1b
7963
Ignacio Vazquez-Abrams
  • 44,857
  • 7
  • 93
  • 100