I need to use an if statement that is true only if "is loaded" AND "is running" occur in a service status command output:
$groupservice status
service 1 is loaded
service 2 is running
As already mentioned I've tried to use this:
$service status | awk '/is loaded/ && /is running/'
but I dont' get any output. The only way to run it is in this way:
if [[ $(service status | grep "is loaded") ]] && [[ $(service status | grep "is running") ]]
but I'd prefer to use a shorter expression. Where am I wrong? thank you