How do I test (in one line) if command output contains a certain string?

后端 未结 3 683
北恋
北恋 2020-12-04 14:55

In one line of bash, how do I return an exit status of 0 when the output of /usr/local/bin/monit --version doesn\'t contain exactly 5.5 and an exit

3条回答
  •  感动是毒
    2020-12-04 15:41

    Test the return value of grep:

    sudo service xyz status | grep 'not' &> /dev/null
    if [ $? == 0 ]; then
       echo "whateveryouwant"
    fi
    

    I would recommend cron, it works fine with SALT stack

提交回复
热议问题