#!/bin/bash MAX=100 COUNTER=$(grep 'non-delivery notification' /var/log/mail.log | wc -l) if [ "$COUNTER" -gt "$MAX" ]; then OUTPUT=$(grep -B 3 -A 2 'non-delivery notification' /var/log/mail.log | head -n 150 | tail -n 25) TEXT="!!WARNING!!\ngrep resulted in more than $MAX 'non-delivery notifications'.\n\n$OUTPUT" echo "delivery notifications are larger than $MAX... Sending Mail..."; printf "$TEXT" | mail -s "Mail Administration" -a from:mc8051@schuetrumpf.net niklas@schuetrumpf.net # printf "$TEXT" fi