#!/bin/sh # An example of how to use the case statement # This program prints out the of files in the current directory that # match each pattern. cfiles=0 hfiles=0 tfiles=0 other=0 arg="test" for file in * do case $file in *.[Cc]|*.cpp) cfiles=`expr $cfiles + 1` ;; *.[hH]) hfiles=`expr $hfiles + 1` ;; *$arg*) tfiles=`expr $tfiles + 1` ;; *) other=`expr $other + 1` ;; esac done echo "There were $cfiles C files" echo "There were $hfiles H files" echo "There were $tfiles test files" echo "There were $other other files"