我有如下 bash 脚本:
#!/bin/bash
echo "Please enter your username";
read username;
echo "Please enter your password";
read password;
我希望当用户在终端上输入密码时,不应该显示它(或者应该显示像 ******* 之类的东西)。我如何做到这一点?
最佳答案
只需将 -s 提供给您的 read 调用,如下所示:
$ read -s PASSWORD
$ echo $PASSWORD
https://stackoverflow.com/questions/4316730/