>[success] # read ~~~ read [选项] [变量名] ~~~ | 选项 | 含义 | | --- | --- | | \-p | 提示信息,在等待read输入时,输出提示信息 | | \-t | 秒数: read命令会一直等待用户输入,使用此选项可以指定等待时间 | | \-n | 字符数,read命令只接受指定的字符数,就会执行 | | \-s | 隐藏输入的数据,适用于机密信息的输入 | ~~~ #!/bin/bash read -p 'please input your name:' -t 5 name echo -e "\n" read -p 'please input you gender[m/f]:' -n 1 gender echo -e "\n" read -p 'please input your password:' -s password echo -e "\n" echo $name,$gender,$password ~~~ * 执行 ~~~ sh read.sh ~~~ * 运行效果 ![](https://img.kancloud.cn/c0/a2/c0a2c0e699e40766ded01aa7b090db33_428x162.png)