#!/bin/sh

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


ARGS=2     # Number of arguments expected
# Exit value if incorrect number of args passed.
E_BADARGS=65

test $# -lt $ARGS && echo "Usage: `basename $0` <string> <filename>" && 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"

