Linux - Multiple service statuses with one command

Posted by Jimbo on Super User See other posts from Super User or by Jimbo
Published on 2013-07-01T20:58:12Z Indexed on 2013/07/01 23:08 UTC
Read the original article Hit count: 248

Filed under:
|
|

I'm trying to retrieve a list of multiple service statuses in Unix. I'm using the service command: man page.

The statuses all start with the transmission-daemon string, for example.

I require the ability to list multiple services' statuses, with a single command. Here is what I'm currently trying (and failing) with:

Here I'm trying to grab a list of statuses using grep.

service $(ls /etc/init.d | grep "transmission-daemon") status

Here I'm trying to list all statuses, and then grep for them.

service --status-all | grep "transmission-daemon"

This produces the following, which isn't much help:

Multiple transmission daemons via grep and service --status-all

How can I effectively achieve what I require with a single command, so that I can then continue piping to awk for further customisation?

Desired example output:

transmission-daemon started
transmission-daemon2 stopped
transmission-daemon3 started

© Super User or respective owner

Related posts about linux

Related posts about grep