Quantcast
Channel: UNIX and Linux Forums
Viewing all articles
Browse latest Browse all 16232

AWK and print next lines #3 thru #10

$
0
0
I have a output log file, that I want to extract some temperature measurement data.

I want to AWK on the words "show chassis environment" in the original file, and extract that entire line, and then the 3rd to 10th lines after the one I AWK'd, into a seperate output file.

Here is an example of the information in the source file :

Code:

20:52:34_23C | root@HWTestEng-Gext%
20:52:35_23C |
20:52:35_23C | root@HWTestEng-Gext% cli show chassis environment
20:52:35_23C |
20:52:35_23C | Class Item                          Status    Measurement
20:52:36_23C |      PCB Left                      OK        33 degrees C / 91 degrees F
20:52:36_23C |      SFP+ Xcvr                      OK        33 degrees C / 91 degrees F
20:52:36_23C |      FEB                            OK        50 degrees C / 122 degrees F
20:52:36_23C |      PCB Up                        OK        33 degrees C / 91 degrees F
20:52:36_23C |      PCB Mid                        OK        36 degrees C / 96 degrees F
20:52:36_23C |      Telecom Mod                    OK        37 degrees C / 98 degrees F
20:52:36_23C |      Routing Engine                OK        31 degrees C / 87 degrees F
20:52:36_23C |      Heater off                   
20:52:36_23C | root@HWTestEng-Gext%

the information I want to extract and export to another file would be:


Code:

20:52:35_23C | root@HWTestEng-Fortius-Gext% cli show chassis environment
 20:52:36_23C |      PCB Left                      OK        33 degrees C / 91 degrees F
20:52:36_23C |      SFP+ Xcvr                      OK        33 degrees C / 91 degrees F
20:52:36_23C |      FEB                            OK        50 degrees C / 122 degrees F
20:52:36_23C |      PCB Up                        OK        33 degrees C / 91 degrees F
20:52:36_23C |      PCB Mid                        OK        36 degrees C / 96 degrees F
20:52:36_23C |      Telecom Mod                    OK        37 degrees C / 98 degrees F
20:52:36_23C |      Routing Engine                OK        31 degrees C / 87 degrees F
20:52:36_23C |      Heater off

Moderator's Comments:
Please view this code tag video for how to use code tags when posting code and data.

Viewing all articles
Browse latest Browse all 16232

Trending Articles