#!/bin/sh usage() { echo "usage: $0 [letter2] [letter3] [...]" exit 1 } [[ ! -f "$1" ]] && echo "file does not exist" && usage [[ "$#" -lt 2 ]] && echo "not enough arguments" && usage file="$1" shift for letter in "$@"; do [[ ! "${#letter}" -eq 1 ]] && echo "argument \"$letter\" too long" && usage echo "$letter -> `cat $file | tr -cd $letter | wc -c`" done