Linux中read接收用户输入

    xiaoxiao2025-09-13  84

    #!/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"
    最新回复(0)