So far with:
#!/bin/bash tail -fn0 /var/log/dirsrv/redacted-domain/audit | \ while read line ; do echo "$line" | grep -C 5 -i "add: member" if [ $? = 0 ] then mail -s "New User Added" email@example.com > /dev/null fi echo "$line" | grep -C 5 -i "add: nsaccountlock" if [ $? = 0 ] then mail -s "Account Disabled" firstname.lastname@example.org > /dev/null fi done
I want to take the contents of grep matches from the file
/var/log/dirsrv/redacted-domain/audit and throw them into an e-mail to
email@example.com. It feels redundant (and does not work regardless) to throw the grep statement into the email itself with the above loop.
Sorry, I should include a sample of what is being grepped:
I want to find a match of type
add: member and return the entire ^ into an email.