search replace retain and compare strings?

I

IJALAB

I have lines like:

$PSTIL,IRQ, 48 bytes
9,9,IDLE,0,0,CC,0,0,MC,1,1,NF,2,2,CD,2,0,AI,1,1,LP,81,83*09

$PSTIL,IRQ,9,9,IDLE,0,0,CC,0,0,MC,1,1,NF,2,2,CD,2,0,AI,1,1,LP,81,83*09

$PSTIL,IRQ,9,37 bytes
9,IDLE,0,0,CC,0,0,MC,1,1,NF,2,2,CD,2,0,AI,1,1,LP,81,83*09

I need to remove these 37 and 48 bytes text from these lines and print
the remaining string to another file. Also I need to check for any
newline characters in the end of every line.

Finally I need to compare each of these line with another file that
also has a similar output and report if any discrepancy exists.
Note: i dont have commas in few lines....so i am unable to split with
commas.

also i am using s/^*.* Bytes*.*//g expression, doesn;t serve the
purpose
Can anyone help in this.

Thanks,
Bala
 
L

Lars Haugseth

* "IJALAB said:
I have lines like:

$PSTIL,IRQ, 48 bytes
9,9,IDLE,0,0,CC,0,0,MC,1,1,NF,2,2,CD,2,0,AI,1,1,LP,81,83*09

$PSTIL,IRQ,9,9,IDLE,0,0,CC,0,0,MC,1,1,NF,2,2,CD,2,0,AI,1,1,LP,81,83*09

$PSTIL,IRQ,9,37 bytes
9,IDLE,0,0,CC,0,0,MC,1,1,NF,2,2,CD,2,0,AI,1,1,LP,81,83*09

I need to remove these 37 and 48 bytes text from these lines and print
the remaining string to another file. Also I need to check for any
newline characters in the end of every line.

s{ \s* \d+ bytes \s* [\r\n]* }{}gxms;
Finally I need to compare each of these line with another file that
also has a similar output and report if any discrepancy exists.

Perhaps you should use "diff" for that.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,048
Latest member
verona

Latest Threads

Top