[Top][All Lists]

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

Re: od bug

From: Bob Proulx
Subject: Re: od bug
Date: Tue, 25 Mar 2008 19:19:48 -0600
User-agent: Mutt/1.5.13 (2006-08-11)

Steve Frampton wrote:
> Linux appears to swap the bytes within the words:

Most Linux kernel based systems are little endian.  So are many
others.  Here is are two references that explains this in some detail.



> address@hidden ~]$ echo "abcdefgh" | od -x
> 0000000 6261 6463 6665 6867 000a

That is the correct output on little endian systems.

> HPUX od shown as a baseline:

HP-UX is a big endian system.  The order of bytes within the word will
be opposite that of a little endian system.

> /home/sframpto--> uname -a
> HP-UX soi_prod B.10.20 A 9000/800 1279364181 two-user license

I am convinced that HP-UX 10.20 which was released in 1996 and is now
12 years old will never die.

> /home/sframpto--> echo "abcdefgh" | od -x
> 0000000 6162 6364 6566 6768 0a00

That is the correct output on big endian systems.

At the root of your confusion is that you are asking od to print
two-byte units (ala PDP-11 16-bit words) with -x.  Using -x is the
same as -tx2.  Words are printed in native byte order.  This is
required by long term legacy and standardized by POSIX.

I would guess what you are wanting is to print bytes.  To print bytes
you would need to use -tx1.

  echo "abcdefgh" | od -tx1
  0000000 61 62 63 64 65 66 67 68 0a

See the FAQ for more information.


Look for "The 'od -x' command prints bytes in the wrong order." for
the section on your question.

> Confidentiality Notice: This transmission (including any
> attachments) is privileged, confidential, and intended only for the
> ...

Those disclaimers are useless.  Many people on public mailing lists
refuse to answer questions posted that included them.  If your company
insists on this annoying behavior then please in the future send your
questions from one of the many free email services provided on the
Internet that does not include this bad behavior.



reply via email to

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