Read option variable name
-P "prompt message"
-t Specifies the wait time, without specifying it waits
-n Specifies the number of characters to be received, without specifying a limit
-S hidden input data, suitable for confidential information input
[Email protected] sh]# VI param_test3.sh
[email protected] sh]# cat param_test3.sh
#!/bin/bash
# Prompt the user to enter and wait 30 seconds and put the input result into the name variable
Read-t 30-p "Please input your name:" Name
Echo-e "\ n"
echo "Name is $name"
# Plus-S will be hidden when entering age
Read-s-T 30-p "Please input your Age:" Age
Echo-e "\ n"
echo "Age is $age"
#-N 1 means only one character is received
Read-n 1-t 30-p "Please input gender m/f:" Gender
Echo-e "\ n"
echo "Genger is $gender"
[Email protected] sh]# sh param_test3.sh
Please input Name:xiaol
Name is Xiaol
Please input your age:
Age is 12
Please input gender m/f: M
Genger is M
[Email protected] sh]#
Receive keyboard input in Linux