Skip to content

Instantly share code, notes, and snippets.

@markusfisch
Last active January 24, 2023 15:15
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save markusfisch/1213846 to your computer and use it in GitHub Desktop.
Save markusfisch/1213846 to your computer and use it in GitHub Desktop.
mkpasswd in bash
#!/usr/bin/env bash
C=${CHARSET:-'abcdefghjkmnpqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ23456789!-_'}
P=
for (( N=${1:-8}; N--; ))
do
P=$P${C:$(( RANDOM%${#C} )):1}
done
echo "$P"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment