Created
November 29, 2022 22:46
-
-
Save carymrobbins/705631c64f10b7c7a1a60e6fc8c82ba5 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
#!/bin/bash | |
set -e | |
n=1 | |
sep=- | |
while [ $# -ne 0 ]; do | |
case "$1" in | |
-n) n=$2; shift; shift;; | |
-s) sep=$2; shift; shift;; | |
*) >&2 echo "Unexpected argument: $1"; exit 1;; | |
esac | |
done | |
cache=$(grep '^[A-Za-z]*$' /usr/share/dict/cracklib-small) | |
len=$(wc -l <<< "$cache") | |
next() { | |
local i=$(shuf -i"1-$len" -n1) | |
echo "$cache" | tail -n"$i" | head -n1 | |
} | |
for ((i = 0; i < n; ++i)); do | |
if [ $i -gt 0 ]; then | |
printf '%s' "$sep" | |
fi | |
printf '%s' "$(next)" | |
done | |
echo |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment