#!/bin/sh set -e usage() { echo "Usage: ${0##*/} [-l length] [chars]" >&2 exit 1 } while getopts 'l:' o; do case "$o" in l) len="$OPTARG" ;; *) usage ;; esac done shift $((OPTIND - 1)) [ $# -gt 1 ] && usage