Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need help removing lines!!!

Status
Not open for further replies.

fsanchez13

Technical User
May 9, 2003
35
US
I am new to scripting but using cgrep -1 +20 I am pulling data from a section of ROP but when I get to this area since there are not 20 lines of section 12 it pulls in section 15.. How can I then go through and pull out the data from section 15 (everything that is red)? This occurs various times in my output.. PLEASE HELP!!!!

TIME 23:59:38
SECTION 12: TRUNK GROUP
ID TGNAME
29
26
27
24
ID IPC OPC OFL MTU USG ITUSG OTUSG
29 0 0 0 0 0 0 0
26 0 0 0 0 0 0 0
27 0 0 0 0 0 0 0
24 0 0 0 0 0 0 0
ID IPCTT OPCTT OFLTT SILC EAIPC EAITU FAOUT
29 0 0 0 0 0 0 0
26 0 0 0 0 0 0 0
27 0 0 0 0 0 0 0
24 0 0 0 0 0 0 0
ID IAMRC RELI INSVC OOS
29 0 0 2 0
26 0 0 16 0
27 0 0 4 0
24 0 0 1 0

========================================
TIME 23:59:38
SECTION 12: TRUNK GROUP
ID TGNAME
28
ID IPC OPC OFL MTU USG ITUSG OTUSG
28 0 0 0 0 0 0 0
ID IPCTT OPCTT OFLTT SILC EAIPC EAITU FAOUT
28 0 0 0 0 0 0 0
ID IAMRC RELI INSVC OOS
28 0 0 6 0



XXXX-XXXXXXXXX 03-05-16 00:05:53 XXXXXX XXXXX XXXXXXX
XX XXXXXX PROC
TIME 23:59:38
SECTION 15: PROCESSOR PERFORMANCE
PERCENT
PROC OCCUP LOAD ORGHC TERMHC INCHC OUTHC PUQCO
AM 1 97 NA NA NA NA NA
1 6 1062 306 150 143 293 0
2 7 1532 336 232 249 484 0


 
something to start with for printing 'sections':

nawk '/SECTION/,/^$/' myFile.txt

vlad
+----------------------------+
| #include<disclaimer.h> |
+----------------------------+
 
vgersh99,

Thank you so much this is amazing!!!! Do you by chance have link to a site where I can read more about NAWK?...
 
One last request. Is it possible to also get the time stamp that shows right above SECTION 12:?
 
nawk '/TIME/,/^$/' myFile.txt

vlad
+----------------------------+
| #include<disclaimer.h> |
+----------------------------+
 
vgersh99,

Thanks I tried this but it didn't work.. See I have 140 SECTIONs that print out every 30 minutes and all I need is the SECTION 12 but I also need the time stamp that shows right above the SECTION 12 line. when I used the nawk '/TIME/,/^$/' myFile.txt it pulls all 140 sections. Any way to get it to pull the line above SECTION 12 or to have it look for to expressions on different lines?
 
do the cgrep, then the nawk ...

cgrep -1 +20 'SECTION 12' myFile.txt | nawk '/TIME/,/^$/'
 
Thank jad but that puts me in the same problem I had at first where on the last section 12 report for each 30 minutes there is not a +20 lines and it pulls in some of section 15 report( it shows on my first post.)..
 
oki, i get you ...

Code:
nawk '/TIME/{currtime=$2} /SECTION 12/{print currtime} /SECTION 12/,/^$/' myfile.txt
[code]

maybe :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top