Linux scripting: hiding user input on terminal

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?

Regards,

JP

Answers


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: