#!/bin/bash set -e set -u usage() { echo "Usage: $0 [-d &2 exit 1 esac done shift $(($OPTIND - 1)) count=${1:-6} if ! [[ $dictionary == *"/"* ]]; then dictionary=/usr/share/dict/"$dictionary" fi if ! [ -e "$dictionary" ]; then echo >&2 "$dictionary does not exist" exit 1 fi egrep '^[a-z]{1,6}$' "$dictionary" | shuf | head -n "$count" | tr '\n' '-' | sed -e 's/-$//' echo