Skip to content

Instantly share code, notes, and snippets.

@carymrobbins
Created November 29, 2022 22:46
Show Gist options
  • Save carymrobbins/705631c64f10b7c7a1a60e6fc8c82ba5 to your computer and use it in GitHub Desktop.
Save carymrobbins/705631c64f10b7c7a1a60e6fc8c82ba5 to your computer and use it in GitHub Desktop.
#!/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