Linux scripting: hiding user input on terminal

I have bash script like the following:


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?




Just supply -s to your read call like so:

$ read -s PASSWORD
$ echo $PASSWORD

Need Your Help

How to update Jre and Jdk

java eclipse ubuntu

I am trying the try with resource statement:

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.