Skip to content

Instantly share code, notes, and snippets.

@pablohdzvizcarra
Created February 29, 2024 04:14
Show Gist options
  • Save pablohdzvizcarra/b8746030126733000836d170bad8ebdc to your computer and use it in GitHub Desktop.
Save pablohdzvizcarra/b8746030126733000836d170bad8ebdc to your computer and use it in GitHub Desktop.
Validates if a password was introduce two times equals
#!/bin/bash
# Program to validate a password
if read -t 10 -sp "Enter secret phrase > " secret_pass; then
echo -e "\nSecret passphrase was configured"
if read -t 10 -sp "Enter the secret phrase again > " secret_pass_two; then
if [[ "$secret_pass" == "$secret_pass_two" ]]; then
echo -e "\nThe password was validated"
else
echo -e "\nThe passwords are not equals $secret_pass and $secret_pass_two"
fi
fi
else
echo -e "\nInput time out" >&2
exit 1
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment