![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| 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. |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
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. |
|
||||
|
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 |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|