#! /bin/bash
#
# You MUST be able to run this script file as:
#    bash findtest
# Do NOT make any changes that makes it fail to execute.
# Change only PUTYOURGREPEXPRESSIONHERE at the end of the three find commands
# (And for Perlsters, you may also change the options for grep)
# Print *only* matching lines!

MATCHFILE=testlines.txt
if [ "$#" -ne 0 ]; then
    MATCHFILE="$1"
fi
echo "Regular line matcher for the file $MATCHFILE"
echo
echo "GREP1:"
echo "   Match lines that start a colon ':'"
grep -E ^: "$MATCHFILE"
echo
echo "GREP2:"
echo "   Match lines that contain A+++ (A followed by three plus signs)"
grep -E "A[+][+][+]" "$MATCHFILE"
echo
echo "GREP3:"
echo "   Match lines that contain the words 'sys' and 'admin'"
echo "   separated by white space, that is, one of more spaces or tabs"
grep -E "sys[[:space:]]+admin" "$MATCHFILE"
echo
echo "GREP4:"
echo "   Match lines that contain at least three digits"
grep -E "[0-9].*[0-9].*[0-9]" "$MATCHFILE"
# grep -E "[[:digit:]].*[[:digit:]].*[[:digit:]]" "$MATCHFILE"
