I've got following script that I thought would only email me when the if clause finds the grep. But it emails me anyway (with an empty file) even if the grep doesn't return anything.
What should the line be?
Code:
if [ "`grep -l 'unique constraint' $LOGDIR/archive_active* | wc -l`" > "0" ]
then grep -l 'unique constraint' $LOGDIR/archive_active* > $LOGDIR/archive_error.lis
mailx -s "Archive_active logging contains unique constraints - ACTION REQUIRED" john@doe.com <<EOF
`cat $LOGDIR/archive_error.lis`
EOF
fi
thanks in advance.
regards, Meert