Subject: bug#41518: Bug in od?

From: Pádraig Brady <[email-masked]>
Date: Mon, 25 May 2020 11:48:20 +0100

tag 41518 notabug
close 41518
stop

response below...

On 25/05/2020 04:05, Yuan Cao wrote:
> Hello,
> 
> I recently came across the following behavior.
> 
> When using "--traditional x2" or "-x" option, it seems the order of hex
> code output for the characters is pairwise reversed (if that's the correct
> way of describing it).
> 
> For example, using "od -cx" on a test file that contains "123456789\n", you
> get the following output:
> 
> 0000000   1   2   3   4   5   6   7   8   9   0  \n
>                   3231  3433  3635  3837  3039  000a
> 0000013
> 
> It seems like it should be the following instead:
> 
> 0000000   1   2   3   4   5   6   7   8   9   0  \n
>                   3132  3334  3536  3738  3930  0a00
> 0000013
> 
> The version involved is od in GNU coreutils 8.28.

That's because you're on a little endian machine.
If you want to reorder as per a big endian machine you can:

   od --endian=big -cx your_file

If you want to hexdump independently of endianess you can:

   od -Ax -tx1z -v

cheers,
Pádraig