使用read讀入變量賦值shell
參數bash
-p 設置提示信息ide
-t 設置超時時間
ip
使用方法:input
[root@shell script]# read -p "pls input :" n pls input :12 [root@shell script]# echo $n 12
特殊用法
it
[root@shell script]# cat jisuan.sh #!/bin/bash read -t 10 -p "Pls input :" a b echo "a+b=$(($a+$b))" [root@shell script]# sh jisuan.sh Pls input : 12 12 a+b=24