#!/bin/sh
# url: http://pank.org/scripts/
# description: multi-grep (and operation), support 5 keywords max
# comment: csh bash
# platform: all

case $# in
    2)
        grep -i $1 $2
	;;
    3)
        grep -i $1 $3 | grep -i $2
	;;
    4)
        grep -i $1 $4 | grep -i $2 | grep -i $3
	;;
    5)
        grep -i $1 $5 | grep -i $2 | grep -i $3 | grep -i $4
	;;
    6)
        grep -i $1 $6 | grep -i $2 | grep -i $3 | grep -i $4 | grep -i $5
	;;
    *)
        echo "Multi-grep (and operation)"
        echo "Usage: `basename $0` {keywords} {file}"
        echo "       5 keywords max"
        echo "   ex. `basename $0` aa bb cc file"
	;;
esac