[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Octal Dump (od) bug

From: Bob Proulx
Subject: Re: Octal Dump (od) bug
Date: Thu, 6 Sep 2001 16:40:14 -0600

> I wanted to report what I think is a bug in the octal dump program.  I
> am using Red Hat Linux 7.1 and tried to use od to check for special
> characters but the the  -x  gave me wrong results.  Here is what I input
> and the results:
>    echo abcdef|od -cx
>    a   b   c  d   e  f   \n  0a
>    6261 6463 6665 000a
> It looks like the -c is working correctly but the -x output is reversed.

Thanks for you report.  But you are seeing little endian output.  In
short, that is the way it is supposed to work.

This following might be a little more clear.  Instead of printing two
bytes print four bytes.  'od -x' is the pre-POSIX form of 'od -t x2',
output in hexidecimal two bytes units.  Let's print four so that it is
easier to read.

On a little endian machine such as an x86 platform you see:

  echo abcd | od -t x4
  0000000 64636261 0000000a

On a big endian machine such as HP PA-RISC you see:

  echo abcd | od -t x4
  0000000 61626364 0a000000

The standards documentation says specifically:

        The byte order used when interpreting numeric values is
        implementation-dependent, but will correspond to the order in
        which a constant of the corresponding type is stored in memory
        on the system.

For more information see the standards documentation:



reply via email to

[Prev in Thread] Current Thread [Next in Thread]