【问题标题】:Print only a part of the result of a command只打印命令结果的一部分
【发布时间】:2017-05-05 17:14:05
【问题描述】:

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

这是我正在使用的命令:

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

这是该命令的结果。

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

这是我想要的输出:inactive (dead)。

【问题讨论】:

    标签: linux shell command centos7


    【解决方案1】:

    可能是这样的:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2021-10-19
      • 1970-01-01
      • 2023-04-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多