#! /bin/sh OPTVAL=`getopt -o cvd: -n 'unhyphenize' -- "$@"` # Note the quotes around `$OPTVAL': they are essential! eval set -- "$OPTVAL" verbose=0 delimiter=" " while true ;do case "$1" in -v) verbose=$(($verbose + 1)) shift ;; -d) delimiter="$2" shift 2 ;; -c) delimiter=" " shift ;; --) shift break ;; *) echo "Internal error!" exit 1 ;; esac done while read ;do line=$REPLY case "$line" in *-) echo -n $(basename "$line" "-") ;; *) echo -n "$line$delimiter" ;; esac done