[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: enhancement request for a long word byte swap option for 'dd'
From: |
Bob Proulx |
Subject: |
Re: enhancement request for a long word byte swap option for 'dd' |
Date: |
Fri, 30 Jun 2006 18:24:14 -0600 |
User-agent: |
Mutt/1.5.9i |
Mike Lockhart wrote:
> What I'm looking for is an end-to-end swap. e.g. swap 0000f841 to
> 41f80000 so that 'od' will return 3.1000000e+01
What options are you using to 'od'?
> I can write a byte-swap function in awk, but I can't translate the
> floats into something I can understand - it would require getting into
> the bit world:
Is perl a possibility? Because the perl snippet I posted should work
fine if perl is available. It is using only basic perl functionality.
printf "abcdefghijklmno\n" | od -tx
0000000 64636261 68676665 6c6b6a69 0a6f6e6d
printf "abcdefghijklmno\n" \
| perl -e 'while (sysread(STDIN,$d,4)){print pack("N",unpack("V",$d));}' \
| od -tx
0000000 61626364 65666768 696a6b6c 6d6e6f0a
There you go...
Bob