To read input from the keyboard and assign input value to a variable use the read command.
Read syntax:
read options var1 var2
To write the value of first entered word use:
read var1 var2
echo $var1
If you don't give any argument to the read command, input will assign to the environment variable REPLY.
The "s" option does not echo input while reading from a keyboard.
read -s -p "Enter password:" $password
The -p "TEXT" option displays TEXT to user without a newline.
The -e option means that command readline is used to obtain the line.
Option -u FD reads inputs from file descriptor FD (0,1,2).
Option -t TIME causes that read returns a failure if input is not read within TIME seconds.
Was this information helpful to you? You have the power to keep it alive.
Each donated € will be spent on running and expanding this page about UNIX Shell.
We prepared for you video course Marian's BASH Video Training: Mastering Unix Shell, if you would like to get much more information.
Thank you. Marian Knezek