On Mon, Aug 20, 2018 at 12:01 PM, Grant Edwards <grant.b.edwa...@gmail.com> wrote: > On 2018-08-20, Ben Bacarisse <ben.use...@bsb.me.uk> wrote: >> Grant Edwards <grant.b.edwa...@gmail.com> writes: >> >>> On 2018-08-20, Steven D'Aprano <steve+comp.lang.pyt...@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 >
Your system is different from mine, then. rosuav@sikorsky:~$ ls -l $(which hd) lrwxrwxrwx 1 root root 7 Apr 12 2017 /usr/bin/hd -> hexdump rosuav@sikorsky:~$ ls -l $(which hexdump) -rwxr-xr-x 1 root root 27248 Apr 12 2017 /usr/bin/hexdump In 'man hexdump', the -C option says: -C Canonical hex+ASCII display. Display the input offset in hexa‐ decimal, followed by sixteen space-separated, two column, hexa‐ decimal bytes, followed by the same sixteen bytes in %_p format enclosed in ``|'' characters. Calling the command hd implies this option. I'm on Debian GNU/Linux, and the 'hexdump' command comes from a package called bsdmainutils. What are you on, and where is your hexdump from? ChrisA -- https://mail.python.org/mailman/listinfo/python-list