#!/bin/sh if [ "$1" = "-n" ] ; then template='[:alnum:]' shift else template='[:alnum:]+=\-_' fi if [ -z "$1" ] ; then echo "usage: $0 [-n] length" >&2 exit 1 fi LC_ALL=C tr -dc "$template"