Alex Cohen Alex Cohen - 1 year ago 65
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.

Answer Source

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"
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download