read 選項 變量名
-p "提示信息"
-t 指定等待時間,不指定則一直等待
-n 指定接收的字符數,不指定則不限制
-s 隱藏輸入的數據,適用於機密信息的輸入
[root@localhost sh]# vi param_test3.sh
[root@localhost sh]# cat param_test3.sh
#!/bin/bash
# 提示用戶輸入並等待30秒,並將輸入結果存入name變量中
read -t 30 -p "Please input you name: " name
echo -e "\n"
echo "Name is $name"
# 加上 -s 以后 輸入age的時候將隱藏起來
read -s -t 30 -p "Please input you age: " age
echo -e "\n"
echo "Age is $age"
# -n 1 代表只接收一個字符
read -n 1 -t 30 -p "Please input gender M/F :" gender
echo -e "\n"
echo "Genger is $gender"
[root@localhost sh]# sh param_test3.sh
Please input you name: xiaol
Name is xiaol
Please input you age:
Age is 12
Please input gender M/F :M
Genger is M
[root@localhost sh]#