当前第2页 返回上一页
1 2 3 4 5 | #!/bin/bash
### Input password as hidden charactors ###
read -s -p "Enter Password: " pswd
### Print the value of pswd variable ###
echo -e "\nYour password is: " $pswd
|
让我们执行脚本并输入密码,您只需输入密码,字符将不会显示在屏幕上。这只适用于/bin/bash shell,较旧的shell(/bin/sh)将抛出一个错误。
让我们执行脚本并输入您的密码,您只需输入密码,屏幕上就不会显示字符。这只适用于/ bin / bash shell,较旧的shell(/ bin / sh)会抛出错误。
1 2 3 4 | # chmod +x inputpwd.sh
# ./inputpwd.sh
Enter Password :
Your password is : 9kjdfk329sksk
|
本篇文章到这里就已经全部结束了,更多其他精彩内容可以关注PHP中文网的Linux教程视频栏目!!!
以上就是如何在shell脚本中以隐藏字符的形式输入密码的详细内容,更多文章请关注木庄网络博客!
返回前面的内容
相关阅读 >>
linux默认的shell是什么
如何调试shell脚本?
linux中shell脚本怎么运行
一文读懂shell编程三剑客之一的sed命令
linux运维之shell变量.md
如何从shell脚本创建二进制文件
shell脚本命令示例
linux怎么执行shell脚本
bash shell:测试文件或目录是否存在
shell编程实战之监控磁盘分区的使用率
更多相关阅读请进入《shell》频道 >>
转载请注明出处:木庄网络博客 » 如何在shell脚本中以隐藏字符的形式输入密码