0

Usually I will use xxd to see what characters I type translate to in hex. For example:

$ xxd

hello
00000000: 0a68 656c 6c6f 0a                        .hello.

However, how would I do the same for:

  • Ctrlz
  • Ctrld
  • Ctrlc

It seems when I enter either of these three it 'does something' outside the xxd program, rather than being recognized as a keyboard input for which I want to see the hex codes. So how can I see those values sent by my keyboard for all character combinations?

carl.hiass
  • 1,526
  • 1
  • 6
  • 26

1 Answers1

1

In the command line console, you can enter codes like Ctrl-Z by first entering Ctrl-V.

So for example, if you type in the following:

xxd <<<'Ctrl-VCtrl-A'

Then you should see the following output:

00000000: 010a                                     ..

(where, as I'm sure you realise, the 01 corresponds to ^A and 0a is the line break that comes after it)

On an ANSI terminal, you can enter escape codes in this way too. For example, type in this:

echo 'Ctrl-VEsc[1;31mHelloCtrl-VEsc[0m world'

to print one word in bright red and another in the default colour.

r3mainer
  • 23,981
  • 3
  • 51
  • 88