Shell脚本一次性从控制台读取多个值

read(选项)(参数) 

shell脚本语言读取参数使用read,他有两个选项可以设置:

-p   读取值时的提示符

-t   读取值等待的时间,如果没有在指定时间内输入,则结束输入

参数就是用来存值的变量的名称,下面是采用shell脚本从控制台一次性读取多个值的代码:

echo "Please enter some paramters:"
read name password age sex
echo "User: $name Password: $password Age:$age Sex:$sex"

猜你喜欢

转载自blog.csdn.net/qq_39429962/article/details/82795897