![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here. |
|
|
||||
| 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 |
|
|
Submit Tools | LinkBack | Thread Tools | Display Modes |
|
#1
|
|||
|
|||
|
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 |
| Forum Sponsor | ||
|
|
|
#2
|
|||
|
|||
|
Try this:
Code:
awk '/^+.*NMInterface/{f=1}
f&&/EntityName:/{print}
f&&/OverallStatus:/{print}
f&&/IfName:/{print;f=0}
' file
|
|
#3
|
|||
|
|||
|
Can't we just use egrep?
#!/bin/sh egrep -e '^+*NMInterface|^EntityName|^OverallStatus|^IfName' myfile |
|||
| Google The UNIX and Linux Forums |