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
Required info on Pstack on solaris10 rajendra44 UNIX for Advanced & Expert Users 0 06-02-2008 05:46 AM
Help required with a Csh script to read data from a file fizzme Shell Programming and Scripting 1 05-29-2008 04:30 PM
Required Script shameeque Windows & DOS: Issues & Discussions 3 02-14-2007 01:19 AM
Urgent help required in deleting a line without opening a file usinga shell script naan Shell Programming and Scripting 6 07-20-2006 12:42 AM
UNIX PATH info required PLEASE HELP (I'm new to unix) akitachi UNIX for Dummies Questions & Answers 1 05-10-2002 11:37 AM

Reply
 
Submit Tools LinkBack Thread Tools Display Modes
  #1  
Old 05-29-2008
Registered User
 

Join Date: May 2008
Posts: 27
Script required to get a required info from file. Pls. help me.

Hi All,

I have Information in the file like,

============ Interface Information ====================
+++++++++++++++++ NMInterface ++++++++++++++
ObjID:251c55a2-2257-71dd-0f68-9887a1f10000
NNMObjID:82857
EntityName:aust00m1.mis.amat.com[ 0 [ 161 ] ]
Description:ATM9/0/0-atm layer
Discovered in Zone:0
EntityType:Interface
IPLevel:4
OverallStatus:NotMon
OADId:0
StatusChangeTime:0
CreateTime:1210839357
ChangeTime:1210839357
Containment Parent:aust00m1.mis.amat.com(1d5ebb70-2257-71dd-0f68-9887a1f10000)
==========Interface Property===============
VPI:0
VCI:0
BoardNo:-
PortNum:0
AuxPortNum:0
IfIndex:161
IfName:AT9/0/0
IfAlias:-
IfType:37
PhysicalAddress:-
L2DomainID:-1
IfOperStatus:2
IfAdminStatus:2
VlanPortType:2001689792
isDiscoContrivedIF:0
IfSpeed:0
IF Capability :


Requirement:

Whenever the string matches "+++++++++++++++++ NMInterface ++++++++++++++" then It should print the following informations.
EntityName:
OverallStatus:
IfName:

Example result:

EntityName:aust00m1.mis.amat.com[ 0 [ 161 ] ]
OverallStatus:NotMon
IfName:AT9/0/0


Note: File contains mutiple records. The above example is one record.

If the string match again it should do the same operation.

I attached example file in this thread. Pls. provide me a script for this requirement.


Thanks,
Gobinathan.S
Reply With Quote
Forum Sponsor
  #2  
Old 05-31-2008
Moderator
 

Join Date: Feb 2007
Posts: 2,199
Try this:

Code:
awk '/^+.*NMInterface/{f=1}
f&&/EntityName:/{print}
f&&/OverallStatus:/{print}
f&&/IfName:/{print;f=0}
' file
Regards
Reply With Quote
  #3  
Old 05-31-2008
Registered User
 

Join Date: May 2008
Posts: 7
Can't we just use egrep?
#!/bin/sh
egrep -e '^+*NMInterface|^EntityName|^OverallStatus|^IfName' myfile
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 02:29 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