The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Shell Script Required? Pls. help me ntgobinath Shell Programming and Scripting 22 05-29-2008 04:09 AM
Shell Script Required! vats Shell Programming and Scripting 3 08-27-2007 11:29 PM
shell script required sethunath Linux 1 07-07-2007 02:04 AM
shell script required sethunath Shell Programming and Scripting 4 07-06-2007 12:39 AM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 05-01-2008
Registered User
 

Join Date: May 2008
Posts: 27
Question Shell Script Required

I have following information in one file.

ObjID: 004ee4e4-0d92-71dd-1512-9887a1f10000
Address: 152.135.0.61
PingState: Ping Responding
----------------Management Address---------------------
++++++++++++++++Interface+++++++++++++++++++++
IFName: dall00r1.mis.amat.com[ 0 [ 2 ] ]
ObjID: 0155c646-0d92-71dd-1512-9887a1f10000
IFAlias: -
IFDescription: GigabitEthernet0/0
Status: Normal
IfIndex: 2
IfType: 6
AggregatedInterfaceObjID: -
Capability: isL2Connected isCDP
----------------Interface---------------------
++++++++++++++++Interface+++++++++++++++++++++
IFName: dall00r1.mis.amat.com[ 0 [ 1 ] ]
ObjID: 0bb25a50-0d92-71dd-1512-9887a1f10000
IFAlias: Dest:AT&T MPLS CLOUD Type: ISP T1 CID:
IFDescription: Serial0/1/0
Status: Normal
IfIndex: 1
IfType: 23
AggregatedInterfaceObjID: -
Capability: isCDP isMulticast
++++++++++++++++Address+++++++++++++++++++++

Requirement:

Now, Whenever it's matches '++++++++++++++++Interface+++++++++++++++++++++' then it should print next 5 lines in the output file.

Pls. anybody gives script for this requirement. I'm new to scripting. Pls. help me out.

Thanks,
Gobinathan.S
Reply With Quote
Forum Sponsor
  #2  
Old 05-01-2008
Registered User
 

Join Date: Apr 2008
Posts: 11
hello try this one out,

hope this helps you

please paste this in a file and make it shell executable by chmod 755 and run it.

awk ' $0 ~ /\+\+\+\+\+\+\+\+\+\+\+\+\+\+\+\+Interface\+\+\+\+\+\+\+\+\+\+\+\+\+\+\+\+\+\+\+\+\+/ {
match_str="YES"; line_cnt=0; next; }
{
if((line_cnt < 5) && ( match_str=="YES"))
{
print $0;
line_cnt += 1;
}
else {
match_str="NO"; line_cnt=0; }
}' inputfile_name
Reply With Quote
  #3  
Old 05-01-2008
rubin's Avatar
Registered User
 

Join Date: Nov 2007
Posts: 216
Code:
awk '/^\++\+Interface\++\+$/{a=NR+1}
 NR==a,NR==a+4{ print }' input > output
Reply With Quote
  #4  
Old 05-06-2008
Registered User
 

Join Date: May 2008
Posts: 27
Thanks to Chappidi!!!

Thanks Chappidi...Your script worked well.
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 12:10 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0