bug-textutils
[Top][All Lists]
Advanced

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

Re: od -x


From: Bob Proulx
Subject: Re: od -x
Date: Mon, 15 Apr 2002 21:39:46 -0600

> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
> <HTML>
> <HEAD>
> <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
> <META NAME="Generator" CONTENT="MS Exchange Server version 5.5.2653.12">
> <TITLE>od -x</TITLE>
> </HEAD>
> <BODY>

In the future when posting messages to mailing lists it would be most
appreciated if you sent your message in plain text format.  HTML mail
is not appreciated.

  http://www.expita.com/nomime.html

> <P><FONT SIZE=2 FACE="Arial">The od utility doesn't seem to behaving 
> properly. With the -x option, it reverses bytes e.g. 5245 4f43 when it should 
> be 4552 434f. With no options, I can detect no correspondence to the actual 
> input data and no pattern whatsoever. What character is an octal 503? The -c 
> option works, but is not so useful.</FONT></P>

Thank you for your report.  However, that is the required behavior
depending upon the endianess of the underlying machine.  I believe you
are mixing up words and bytes.  The documentation could be more clear
on that point.  It seems like you are interested in byte ordering but
are using word ordering.

The -x option outputs short integers, note integers which is a word
and not a byte, in the machine's short integer format.  If you are
operating on a little endian machine such as an x86 then the bytes
appear in 'backwords' order.

`-x'
     Output as hexadecimal shorts.  Equivalent to `-tx2'.

If you require a specific byte ordering, note bytes not words, then
you need to supply a byte specification such as 'od -t x1'.

  echo abcdefgh > /tmp/letters
  od -cx /tmp/letters
  0000000   a   b   c   d   e   f   g   h  \n  \0
          6261 6463 6665 6867 000a
  0000011
  od -t cx1 /tmp/letters
  0000000   a   b   c   d   e   f   g   h  \n
          61 62 63 64 65 66 67 68 0a
  0000011

See the online 'info od' documentation for details of the format
specification.  See the online standards documention for standards
conformance information.

  http://www.unix-systems.org/single_unix_specification_v2/xcu/od.html

If you search the web for 'little endian big endian' you should turn
up many hits for various documentation on this subject.  But for sure
you should read this one written by Danny Cohen published in IEEE
Computer years ago as it is a classic treatise on the subject.

  http://www.op.net/docs/RFCs/ien-137

HTH
Bob



reply via email to

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