#!/bin/sh
# Counts the number of times first parameter (string) occurs in a
# file.

# make sure we have the right number of arguments passed in
ARGS=2       # Number of arguments expected.
E_BADARGS=65  # Exit value if incorrect number of args passed.

test $# -lt $ARGS && echo "Usage: `basename $0` <whichstring> <whichfile>" && exit $E_BADARGS


# Parameter 1: string
# Parameter 2: file
numwords=`grep $1 $2 | wc -l`

echo "The number of lines in $2 that contain $1 is $numwords"

