Linux中read接收用户输入

#!/bin/bash

#提示Please input your name并等待20秒,把输入内容存入变量name中
read -t 20 -p "Please input your name: " name
echo "input name is $name"


#-s选项隐藏输入,用于隐藏项
read -s -t 20 -p "Please enter your password: " pwd
echo -e "\n"
echo "input password is $pwd"


#-n 1表示只接收一个输入字符就会执行,不需要输入回车
read -n 1 -t 20 -p "Please input your gender[M/F]:" gender
echo -e "\n"
echo "input gender is $gender"

上一篇:Linux 升级make (gmake)


下一篇:Supervisor进程管理