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 Expert-to-Expert. Learn advanced UNIX, UNIX commands, Linux, Operating Systems, System Administration, Programming, Shell, Shell Scripts, Solaris, Linux, HP-UX, AIX, OS X, BSD.

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 10-05-2007
hare hare is offline
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.
  #2 (permalink)  
Old 10-06-2007
dennis.jacob dennis.jacob is offline Forum Advisor  
dj - the student
  
 

Join Date: Feb 2007
Location: Singapore/Bangalore/Cochin
Posts: 607
For the qn 1,
Code:
sed 's/\(.*\) OBJ:\(.*\)/OBJ:\2/' filename
For qn2, could you explain it in detail what exactly u need?
  #3 (permalink)  
Old 10-06-2007
hare hare is offline
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
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 02:22 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0