From: Oisin McGuinness <oisin@smbc-cm.com>
Subject: Re: od for big_endian?
Date: Wed, 13 Jun 2001 11:55:53 -0400 [thread overview]
Message-ID: <3B278D09.BE85D77E@smbc-cm.com> (raw)
In-Reply-To: 9g5c3r$jaq$1@geraldo.cc.utexas.edu
yosuke@ccwf.cc.utexas.edu wrote:
> Thank you for the tip. I never knew about dd's conv= command. I tried
> but that didn't fix the problem completely. conv=swab swaps first and
> second byte, third and forth byte and so on. What I want to do is swap
> first and forth, second and third. So if I had
>
> af46 00c9
>
> I want
>
> c900 46af
>
> as output.
OK, here is a perl 1 liner which acts as a filter to do this:
perl -e 'while((sysread STDIN, $buffer, 4)>0) { syswrite(STDOUT,
reverse($buffer), 4, 0);}'
(this may not handle the case where the input file is not 4*something in
size correctly, and as
per the perl documentation, one should really handle interrupted system
reads and partial writes, see
the perl documentation of syswrite for details.
>
> Also, I coudn't figure out how to pipe the dd output. I tried od=\| and
> it created a file called '|'.
You don't need to specify of=| to dd to make it act as a filter, just
leave out
the of= specification; if dd had done the job then,
dd conv=swab <infile | od
would have displayed stuff.
>
--
Oisin McGuinness
SMBC Capital Markets
277 Park Avenue
New York NY 10172
USA
(212)-224-4913, email: oisin@smbc-cm.com
(Changed April 2 2001 from oisin@sbcm.com.)
prev parent reply other threads:[~2001-06-13 15:55 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2001-06-11 23:56 od for big_endian? yosuke
2001-06-12 12:16 ` Oisin McGuinness
2001-06-12 15:22 ` yosuke
2001-06-13 15:55 ` Oisin McGuinness [this message]
read-only archive
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox