addady
asked on
bash shell "if not"
How can I change this if:
if grep "Slave_Running: Yes" /home/status.txt > /dev/null; then
echo Mailing show slave status error report!!!
/home/mysql-mail-problem.s h
fi
to "if not"
Thanks
Addady
if grep "Slave_Running: Yes" /home/status.txt > /dev/null; then
echo Mailing show slave status error report!!!
/home/mysql-mail-problem.s
fi
to "if not"
Thanks
Addady
ASKER
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 h
fi
./tmp.sh
./tmp.sh: [: Slave_Running: Yes: binary operator expected
> 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
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
(you need to check first which exist status of grep you're interested in)