Skip to content

Instantly share code, notes, and snippets.

@guumaster
Created March 8, 2013 23:58
Show Gist options
  • Save guumaster/5121476 to your computer and use it in GitHub Desktop.
Save guumaster/5121476 to your computer and use it in GitHub Desktop.
Read password from stdin
#!/bin/bash
unset password
prompt="Secret Password:"
while IFS= read -p "$prompt" -r -s -n 1 char
do
if [[ $char == $'\0' ]]
then
break
fi
#prompt='*' # to show * for every keystroke
prompt=''
password+="$char"
done
#echo "your password is: $password"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment