I could need some help with a oneline script im building. The script should give me a list of services, which are running on the current system. I wanted to realize this with systemctl.
The current oneliner looks like this:
systemctl list-units --type service | grep -f /etc/update-motd.d/service.list
However this command always creates a blank line between the services which are listed
smbd.service loaded active running Samba SMB Daemon
uuidd.service loaded active running Daemon for generating UUIDs
virtlogd.service loaded active running Virtual machine log manager
zabbix-agent.service loaded active running Zabbix Agent
I would like to remove the empty spaces. After some google research ive found some solutions with tr (like 'tr -d ""' or 'tr -s ""'), but this doesnt seem to work. Ive even tried some solutions with grep or sed but none of them helped me wih this.
edit: following solutions I tried without success: | grep "." | sed '/^$/d | grep "\S"
Some help would be great! Thanks