I am looking at a compiled java file on Ubuntu 22.04.
On bash, when i say xxd A.class
, i get a hexdump that begins with cafe babe
- this is what i expect.
But if i say od -x A.class
, i get feca beba
- why?
As an additional puzzler, both if is say tac A.class | xxd
(reversal by line) AND tac -r -s 'x\|[^x] | xxd
(reversal by character) i get the cafe babe pattern, while both cases piped into od -x
instead of xxd
give feca beba
- Here the reversal by character should result in one result of beba feca
, or at least babe cafe
, should it not? Please enlighten me. The fe
represents one byte, is it not?
Yes, both commands are using different endianess for integer representation. It has already been discussed in https://stackoverflow.com/a/41229024/20161294