Reputation: 7
I am new to shell scripting . i want to make the password not visible when we type password ..can you please suggest me on this
echo "enter your password"
read pass
if [ "$pass" != "" ]
then
echo "thank you "
else
echo "invalid password"
exit
fi
Upvotes: 0
Views: 332
Reputation: 3449
Alternatively, if you issue in your bash prompt:
help read
You will find out that you can use a switch.
-s do not echo input coming from a terminal
Thus simply using read -s pass
will solve your problem.
Upvotes: 2
Reputation: 5721
Use
# turn echo off
stty -echo
...
# turn echo back on
stty echo
Upvotes: 1