Linux的脚本:在终端隐藏用户输入 [英] Linux scripting: hiding user input on terminal
本文介绍了Linux的脚本:在终端隐藏用户输入的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有bash脚本如下所示:
I have bash script like the following:
#!/bin/bash
echo "Please enter your username";
read username;
echo "Please enter your password";
read password;
我想,当用户类型的终端上的密码,它不应该被显示(或者类似的东西*******)应显示)。我如何做到这一点?
I want that when the user types the password on the terminal, it should not be displayed (or something like *******) should be displayed). How do I achieve this?
问候,
JP
推荐答案
只需提供-s你读的呼叫,像这样:
Just supply -s to your read call like so:
$ read -s PASSWORD
$ echo $PASSWORD
这篇关于Linux的脚本:在终端隐藏用户输入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文