read:取自键盘输入的变量

要读取来自键盘输入的变量,就用read命令

read [-pt] variable
-p:后面接提示符
-t:后面接等待的秒数

#测试1
zmc@SUSE11:~> read test
abc
zmc@SUSE11:~> echo $test
abc
#测试2
zmc@SUSE11:~> read -p "please input (y/n):" confirm
please input (y/n):n       
zmc@SUSE11:~> echo $confirm
n
#测试3
zmc@SUSE11:~> read -t 5  -p "please input (y/n):" confirm
please input (y/n):zmc@SUSE11:~> `

你可能感兴趣的:(read:取自键盘输入的变量)