#!/bin/sh

clear
count=0

[ -z "$1" ] && {
cat << !

 Use one word, or multiple words in quotes, e.g.,
    
 recipe "lizard vomit cakes"

!
exit
}

cd /usr/share/MealMaster
COUNT=$(grep -ic "$1" AllTitles.txt)
echo "Your query has returned $COUNT results."
[ $COUNT -eq 0 ] && exit

while [ 1 ]
do
echo -en '\nSee the list, View recipes, or Quit? '
read
clear
case $REPLY
in
    s|S) grep -i "$1" AllTitles.txt | tr -s ' ' | cut -d ' ' -f 2- | sort \
	| less -P "Press 'q' to exit viewer" ;;
    v|V) FNAME=$(mktemp /tmp/recipe.XXXXXX)
	 for n in $(grep -i "$1" AllTitles.txt | sort |awk '{print $1}' | uniq)
	 do 
	     clear
	     echo "Collating files containing \"$1\" - $n..."
	    zcat $n>>$FNAME
	done
	less -ip title.*"$1" $FNAME
	rm $FNAME ;;
    *)  exit ;;
esac

clear
done

    Source: geocities.com/thetropics/5011/scripts

               ( geocities.com/thetropics/5011)                   ( geocities.com/thetropics)