仅打印命令结果的一部分

时间:2017-05-05 17:14:05

标签: linux shell command centos7

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

这是我正在使用的命令:

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

这是该命令的结果。

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

这是我想要的输出:无效(死)。

1 个答案:

答案 0 :(得分:0)

也许是这样的:

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