Linux_Shell_脚本参数接收键盘输入

 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#!/bin/bash
 
 
#提示“请输入姓名”并等待30秒,把用户的输入保存入变量name中
read -t 30 -p "请输入用户名称:" name
echo -e " "
echo "用户名为:$name"
 
#提示“请输入密码”并等待30秒,把用户的输入保存入变量age中,输入内容隐藏
read -t 30 -s -p "请输入用户密码:" age
echo -e " "
echo "用户密码为:$age"
 
#提示“请输入性别”并等待30秒,把用户的输入保存入变量sex中,只接受一个字符输入
read -t 30 -n 1 -p "请输入用户性别:" sex
echo -e " "
echo "性别为$sex"
原文地址:https://www.cnblogs.com/cxhfuujust/p/8078580.html