I wish to sweep a log file and email an alert if errors are found. Basic logic is to search the Oracle listener log for strings having a "TNS-" prefix. If the word count is positive, throw the alert. Certain TNS strings are benign, therefore we generate a whole lot of garbage email.
The target, then, is to exempt the benign ones -- but my Bash skills aren't up to it, Can anyone teach me how to count "TNS-" but not include "TNS-12456", etc.?
if [ -f $LISTENER_LOG_FILE ]; then
# if [ `grep "TNS-" $LISTENER_LOG_FILE | wc -l` -ne 0 ]; then
if [ `grep "TNS-12546" $LISTENER_LOG_FILE | wc -l` -ne 0 ]; then
echo -e "\nThe $LISTENER_LOG_FILE file contains errors." > $LOG_FILE
echo -e " " >> $LOG_FILE
grep "TNS-12546" $LISTENER_LOG_FILE >> $LOG_FILE