I want to grep a specific status of a service (
Only if the string was found, I want to execute some logic.
Problem: even if I execute the script on service name that does not exist ("asd" in this example), the
if $status still matches and prints out. But why?
status = $(systemctl status asd.service | grep 'active') echo $status if $status then echo "$SERVICE was active" exit 0 fi exit 0
Result output is:
asd.service was active, which is certainly not true.
echo $status prints:
status: Unknown job: =