5

If I opened hexdump without any argument in the terminal:

hexdump

When I type something in the terminal and press Enter, hexdump will display the hex values for whatever characters I type.

But hexdump will only display the hex values if I type 16 characters, for example:

enter image description here

Here, I typed the character a 15 times and I pressed Enter(so hexdump received 16 characters (15a + \n)).

But if I type less than 16 characters, for example:

enter image description here

Here, I typed the character a 14 times and I pressed Enter(so hexdump received 15 characters (14a + \n)). And in this case hexdump did not display anything.

Can I make hexdump display the hex values for whatever length of characters it receives instead of it waiting for 16 characters to be received?

Note: I do not want to "use options both for hexdump and xxd to display one byte as hex per line" (as suggested in a comment here). What I want to do basically is for example to know what the hex value for A without having to type an extra 15 characters to get it.

  • IIRC output lines are buffered by default, not sure ATM if you can change that from the shell. But you can use options both for hexdump and xxd to display one byte as hex per line, would that be acceptable? – dirkt Nov 4 '17 at 7:56
  • Try hexdump -v -e '/1 "%02X\n"'. Then you only have to type A and return to know the hex value for A. You still have to type return, because the shell buffers the input line. man ascii also works. :-) – dirkt Nov 4 '17 at 8:55
  • Unneeded screenshots are evil, please use text copy-paste if it is possible. – peterh Feb 8 '18 at 12:06
0

Try hexdump -v -e '/1 "%02X\n"'. That displays one hex byte per line, so the line output buffering won't stop the line from being displayed.

Then you only have to type A and return to know the hex value for A. You still have to type return, because the shell buffers also does line buffering on the input.

man ascii also works. :-)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.