要读取来自键盘输入的变量,就用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:~> `
网友评论