The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Advanced & Expert Users
Google UNIX.COM


UNIX for Advanced & Expert Users Advanced UNIX and Linux questions go here. Expert-to-Expert.

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

Join Date: Oct 2007
Posts: 3
A question on using sed or awk

Hi I have a pattern like this. repeating many lines
CHANGE #13 TYP:22 CLS: 21 AFN:12 DBA:0x0040a15f OBJ:41142 SCN:0x0000.00036b3e SEQ:1 OP:11.2
CHANGE #15 TYP:32 CLS: 32 AFN:212 DBA:0x0040a15f OBJ:41143 SCN:0x0000.00046b3e SEQ:1 OP:13.3
.
And i am trying to do the following:
a) I need to get an output like this
OBJ:41142 SCN:0x0000.00036b3e SEQ:1 OP:11.2
OBJ:41143 SCN:0x0000.00046b3e SEQ:1 OP:13.3
So basically strip all content from Change # till the start of OBJ.
.
b)Secondly once i get (a) done i want some kind of a calculation like
OBJ:41142 SCN:224062 SEQ:1 OP:11.2
OBJ:41143 SCN:289598 SEQ:1 OP:13.3
where in the scn values are derived based on some calculation like
the decimal equivalent of first *4GB+the decimal equivalent of second.
.
Are these possible using sed or awk?
Thanks,
Hare.
Reply With Quote
Forum Sponsor
  #2  
Old 10-05-2007
dj -------
 

Join Date: Feb 2007
Location: Cochin/Bangalore, India
Posts: 439
For the qn 1,
Code:
sed 's/\(.*\) OBJ:\(.*\)/OBJ:\2/' filename
For qn2, could you explain it in detail what exactly u need?
Reply With Quote
  #3  
Old 10-06-2007
Registered User
 

Join Date: Oct 2007
Posts: 3
Hi,
Thanks. That works of sed 's/\(.*\) OBJ:\(.*\)/OBJ:\2/'
.
Assuming the output now i get is this after executing above line
OBJ:41142 SCN:0x0000.00036b3e SEQ: 1 OP:11.2
OBJ:......
.
I want a final output as
OBJ:41142 SCN:0x0000.00036b3e SEQ: 1 OP:11.2
where
the decimal equivalent of first part say 0x0000 is 0 and of
second part namely 00036b3e is 224062
so 0+224062=224062
So the output should become
OBJ:41142 SCN:224062 SEQ: 1 OP:11.2
.
Thanks,
Hare
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 09:41 AM.


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