read:取自键盘输入的变量

2016-12-18  本文已影响0人  njlkj

要读取来自键盘输入的变量,就用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:~> `
上一篇下一篇

猜你喜欢

热点阅读