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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do to grep some information on different line 1

Status
Not open for further replies.

l3p15

Vendor
May 7, 2005
11
TH
Hi

I need to grep some data from the same syntax, but still not work perfectly :

cat RBS_100310_old | sed -e 's/=/ /g' -e 's/,/ /g' | awk '/mobrowser_pid/ {getline;getline;$7,$9}' just get Subnetwork n Mecontex
but i can not get specific problem on different line.

really appriciate any assistant and clue.

Regards,
lepi

from data below :

$mobrowser_pid = 7727

Connected to 10.149.13.41 (SubNetwork=NRO_RootMo_R,SubNetwork=RNC01,MeContext=3G_BIAS,ManagedElement=1)
Connected to 10.149.13.41 (SubNetwork=NRO_RootMo_R,SubNetwork=RNC01,MeContext=3G_BIAS,ManagedElement=1)
Last MO: 1549. Loaded 1549 MOs. Total: 1550 MOs.

3G_BIAS> alt


100310-07:41:24 202.149.13.41 7.1p RBS_NODE_MODEL_L_10_9 stopfile=/tmp/6950
Resolving the alarm service in OMS...
Simple Alarm Client initialized...
Starting to retrieve active alarms
Nr of active alarms are: 3
================================================================================================
Date & Time (Local) S Specific Problem Cause Mo-Reference
================================================================================================
2010-03-03 12:56:10 w IMA Link Reception Unusable at Far End remote_node_transmission_error ImaGroup=1-1-ima1,ImaLink=3
2010-03-03 16:46:52 M Loss of Tracking replaceable_unit_problem Synchronization=1
2010-03-03 17:00:18 m Loss of Synch Reference Redundancy replaceable_unit_problem Synchronization=1
 
Looks like you're 99% of the way there, you just forgot to "print" your results, e.g. {getline;getline; [red]print [/red] $7,$9}.

I'd also recommend removing the sed by defining a different field separator for the awk script using -F, and eliminate the unnecessary cat, e.g.

Code:
awk -F '[ ,=]+' '/mobrowser_pid/ {getline;getline;print $7,$9; print}' RBS_100310_old

Annihilannic.
 
Sorry, typo, take out the second "print" that I left in there by mistake.

Annihilannic.
 
Very appreciate, its solved my first problem buat i need also grep some line together and join them,

Subnetwork, Mecontex, 2010-03-03 16:46:52 M Loss of Tracking replaceable_unit_problem Synchronization=1

any clue to joint this argument..


 
How do you identify which lines you want to join? Are you searching for particular strings? Or do you just want to list a line like that for each alarm,e.g.

Code:
RNC01 3G_BIAS 2010-03-03 12:56:10 w IMA Link Reception Unusable at Far End remote_node_transmission_error ImaGroup=1-1-ima1,ImaLink=3
RNC01 3G_BIAS 2010-03-03 16:46:52 M Loss of Tracking                    replaceable_unit_problem  Synchronization=1
RNC01 3G_BIAS 2010-03-03 17:00:18 m Loss of Synch Reference Redundancy  replaceable_unit_problem  Synchronization=1

Annihilannic.
 
Dear Annihilannic,

absolutely like what you wrote.

WR,
Lepi


RNC01 3G_BIAS 2010-03-03 12:56:10 w IMA Link Reception Unusable at Far End remote_node_transmission_error ImaGroup=1-1-ima1,ImaLink=3
RNC01 3G_BIAS 2010-03-03 16:46:52 M Loss of Tracking replaceable_unit_problem Synchronization=1
RNC01 3G_BIAS 2010-03-03 17:00:18 m Loss of Synch Reference Redundancy replaceable_unit_problem Synchronization=1
 
Try this:

Code:
awk -F '[green][ ,=]+[/green]' '
        [green]/mobrowser_pid/[/green] { [b]getline[/b]; [b]getline[/b]; subnetwork=[blue]$7[/blue]; mecontext=[blue]$9[/blue] }
        [green]/^[0-9][0-9][0-9][0-9]-/[/green] { [b]print[/b] subnetwork,mecontext,[blue]$0[/blue] }
' RBS_100310_old

Annihilannic.
 
Absolutely working perfect...

Thx alot Annihilannic, but I might to ask ...
what the meaning /^[0-9][0-9][0-9][0-9]-/ coz I tried to understand but I can not.

Regards,
Lepi
 
^ matches the beginning of a line.

[0-9] matches any single digit.

So the entire expression matches 4 digits at the beginning of a line, followed by a dash, which in this case is the year of on of the alarm's timestamps.

Annihilannic.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top