Writing bytes to stdout reverses the bytes

Grant Edwards grant.b.edwards at gmail.com
Sun Aug 19 22:01:53 EDT 2018


On 2018-08-20, Ben Bacarisse <ben.usenet at bsb.me.uk> wrote:
> Grant Edwards <grant.b.edwards at gmail.com> writes:
>
>> On 2018-08-20, Steven D'Aprano <steve+comp.lang.python at pearwood.info> wrote:
>>> On Mon, 20 Aug 2018 00:31:35 +0000, Steven D'Aprano wrote:
>>>
>>>> When I write bytes to stdout, why are they reversed?
>>>
>>> Answer: they aren't, use hexdump -C.
>>
>> One might think that dumping out bytes in the correct order ought to
>> be the default format for hexdump.
>
> It is if you run it as hd.

What do you mean "run it as hd"?

I don't see any mention of it the hexdump manpage, and I don't have an
"hd" in my path.  Some commands alter their behavior based on argv[0],
so I created an alias named "hd" that points to hexdump, but that
doesn't do anything any different than "hexdump":

$ which hexdump
/usr/bin/hexdump

$ ls -l $(which hd)
lrwxrwxrwx 1 grante users 16 Aug 19 21:00 /home/grante/bin/hd -> /usr/bin/hexdump

$ hd .bashrc | head -n2
0000000 2023 652f 6374 732f 656b 2f6c 622e 7361
0000010 7268 0a63 0a23 2023 6854 7369 6620 6c69

$ hexdump .bashrc | head -n2
0000000 2023 652f 6374 732f 656b 2f6c 622e 7361
0000010 7268 0a63 0a23 2023 6854 7369 6620 6c69






More information about the Python-list mailing list