Skip to content
Advertisement

Print only a part of the result of a command

I am trying to obtain the status of a httpd service with Centos 7. I want to know if i can print only the value of Active, that in this example is inactive (dead)

This is the command that i am using:

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

This is the result of that command.

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

This is the output that i a want: inactive (dead).

Advertisement

Answer

Maybe something like this:

/bin/systemctl status  httpd.service | grep -o "w*ctive "
User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement