Alex Cohen Alex Cohen - 2 months ago 4x
Linux Question

How to 'read -s' in shell?

I know that user input can be read silently using bash with

read -s someVar
and I was wondering if there is a
equivalent that allows user input without displaying it on the command line?

Note: I am just curious if
supports this feature somehow.


Use the stty command to turn off echoing of typed characters.

get_entry () {
  printf "Choose: "
  stty -echo
  IFS= read -r choice
  stty echo
  printf '\n'


printf "You chose %s\n" "$choice"