[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#10045: Unix od command, reverses hex bytes in output
From: |
Eric Blake |
Subject: |
bug#10045: Unix od command, reverses hex bytes in output |
Date: |
Mon, 14 Nov 2011 10:40:27 -0700 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:7.0.1) Gecko/20110930 Thunderbird/7.0.1 |
tag 10045 notabug
thanks
On 11/14/2011 07:56 AM, address@hidden wrote:
> On Red Hat, the od command reverses the hex bytes.
> address@hidden PatientLoadDataFiles]$ cat a
> 123456
> address@hidden PatientLoadDataFiles]$ od -cx a
> 0000000 1 2 3 4 5 6 \n \0
> 3231 3433 3635 000a
>
> On HP-UX, it prints what you'd expect.
> plr02:lrxiusr:/plr02_users/lrxiusr/artdadamo> od -cx a
> 0000000 3132 3334 3536 0a00
> 1 2 3 4 5 6 \n
>
> Is this a big-endian/little-endian issue?
Absolutely, which means it's not a bug, but a requirement by POSIX.
http://pubs.opengroup.org/onlinepubs/9699919799/utilities/od.html
If you want to output bytes in hex, then don't use the shorthand '-x'
(which is hardcoded to picking up machine-size short words, as in -tx2,
and thus exposes endianness issues), but instead use an explicit '-tx1'.
I'm closing this report.
--
Eric Blake address@hidden +1-801-349-2682
Libvirt virtualization library http://libvirt.org
signature.asc
Description: OpenPGP digital signature