I am trying to get the service whether it is installed or not. The script is working fine with systemctl but fails where systemctl is not installed. As an alternative to that I am using service command to check but by doing so I am unable to run the grep command to grep specific service. This script needs to run on multiple linux machine (some with systemctl and some without it). Any help would be appreciated

test.sh

```
#!/bin/bash

serviceName=ngnix.service

if (systemctl --all --type service || service --status-all) && grep -q "$serviceName";then
    echo "$serviceName exists."
else
    echo "$serviceName does NOT exist."
fi

```

output without systemctl:

```
./test.sh: line 5: systemctl: command not found
 [ ? ]  hwclock.sh
 [ - ]  mariadb
 [ - ]  nginx
 [ - ]  nginx-debug
 [ - ]  procps
 [ - ]  redis-server
 [ - ]  rsync

```

output with systemctl:

```
ngnix.service does NOT exist.

```