只打印命令结果的一部分

Print only a part of the result of a command

我正在尝试使用 Centos 7 获取 httpd 服务的状态。 我想知道我是否可以只打印 Active 的值,在这个例子中它是不活动的(死)

这是我正在使用的命令:

 [root@localhost ~]# service httpd status | grep Active

这是该命令的结果。

 Redirecting to /bin/systemctl status  httpd.service
       Active: inactive (dead)

这是我想要的输出:不活动(死)。

也许是这样的:

/bin/systemctl status  httpd.service | grep -o "\w*ctive "