#!/bin/sh -u # $0 arg [args...] # Count the characters in each string argument. # -IAN! idallen@ncf.ca export PATH=/bin:/usr/bin umask 022 # Must have one or more arguments. # if [ $# -eq 0 ]; then echo 1>&2 "$0: Expecting 1 or more arguments; found $# ($*)" exit 1 fi # Count the characters in each argument. # Generate a special message for empty arguments. # for arg do # Suppress the newline on the echo (could also use "tr -d"). count=$(echo -n "$arg" | wc -c) echo "Argument '$arg' contains $count characters." if [ $count -eq 0 ]; then echo "The argument is empty." fi done