The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
.
google unix.com




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #1 (permalink)  
Old 03-10-2009
Meert's Avatar
Meert Meert is offline
Registered User
  
 

Join Date: Sep 2007
Posts: 8
if clause with grep and word count

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