1

I have a table with some server details and I need to extract their status

Server            Server-ID        Hostname         Last Online               Status        
------------     -----------       ---------        --------------            ------
server1                                             2018-Mar-13 21:39:45      RUNNING
server2                                             2018-Mar-13 21:39:35      RUNNING
server3                                             2018-Mar-13 21:51:32      RUNNING
server4          XX-YY             ubuntu           2018-Mar-13 21:55:04      RUNNING
server5                                             2018-Mar-13 21:52:48      RUNNING
server6                                             2018-Mar-13 21:43:58      RUNNING  

Output required:

RUNNING
RUNNING
RUNNING
RUNNING
RUNNING
RUNNING

From the above table I need to get the Status of all the servers. The columns Server-ID and Hostname can be empty or have a couple of entries. What is the simplest way I can do this? I tried a couple of awk commands but didnt find a complete solution

skorada
  • 431
  • 1
  • 4
  • 15
  • 1
    `tried a couple of awk commands` please add those to question.. else it'd come across as asking for free coding service which isn't a fit for this forum – Sundeep Mar 14 '18 at 07:19

1 Answers1

1

Simple awk will help.

awk 'FNR>2{print $NF}' Input_file

Explanation: Checking condition FNR>2 which checks if line number is greater than 2 then only proceed with further commands. {print $NF} means to print the last column's value.

RavinderSingh13
  • 130,504
  • 14
  • 57
  • 93