Created
May 1, 2018 12:00
-
-
Save jrha/398b98fa4dc21f5d5f07195f36fc389b to your computer and use it in GitHub Desktop.
Bash function to generate a simple, random, but pronouncable username
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function generate_username { | |
# Generate a simple, random, but pronouncable username | |
username="" | |
for i in {1..4}; do | |
if [[ $((i%2)) == 0 ]]; then | |
charset="aeiou" | |
else | |
charset="bcdfghjklmnpqrstvwxyz" | |
fi | |
username="$username$(tr -dc "$charset" < /dev/urandom | head -c 1)" | |
done | |
username="$username$(tr -dc "0-9" < /dev/urandom | head -c 2)" | |
echo "$username" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment