grep exit status should be is 0 if selected lines are found and 1 otherwise. in my case when the line "Slave_Running: Yes" not appent in the file I want to enter to the if.
> if [ ! grep ... ]; then
I add it and it fail on error
# if grep "Slave_Running: Yes" /home/status.txt > /dev/null; then
if [ ! grep "Slave_Running: Yes" /home/status.txt > /dev/null ]; then
echo Mailing show slave status error report!!!
/home/mysql-mail-problem.s
fi
./tmp.sh
./tmp.sh: [: Slave_Running: Yes: binary operator expected
Main Topics
Browse All Topics





by: ahoffmannPosted on 2002-11-17 at 11:18:49ID: 7460292
if [ ! grep ... ]; then
(you need to check first which exist status of grep you're interested in)