How to read just a single character in shell script

footy picture footy · Jan 4, 2012 · Viewed 30.1k times · Source

I want similar option like getche() in C. How can I read just a single character input from command line?

Using read command can we do it?

Answer

SiegeX picture SiegeX · Jan 4, 2012

In bash, read can do it:

read -n1 ans