Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I pass ESC to stdin?

Tags:

linux

shell

How do I pass Esc to stdin in shell, the Esc on a keyboard?

I have discovered that 0x1B or ^[ is the outputted result of Esc but how can I input Esc?

like image 834
jk-kim Avatar asked Oct 27 '25 16:10

jk-kim


1 Answers

On most keyboards, it can be entered as control[.

In a shell script, you could do this (which is part of the POSIX shell):

printf '\033'

and in GNU echo, you may do

echo -e '\e'

Piping either to a script makes that the script's standard input ("stdin"):

printf '\033' | myscript
like image 184
Thomas Dickey Avatar answered Oct 30 '25 06:10

Thomas Dickey



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!