Hi
I have 2 log files, each with a timestamp on the first 2 fields.
However, when I do a
awk '/ / {print $1,$2}' logs/x.log
on a log file,
it is complicated by the fact that I also get other non timestamp
column,
2008-10-20 15:00:06,113
2008-10-20 15:00:06,113
2008-10-20 14:59:48,828
javax.naming.Co mmunicationExce ption: Could
at org.jnp.interfa ces.NamingConte xt.checkRef(Nam ingContext.java :1414)
at org.jnp.interfa ces.NamingConte xt.lookup(Namin gContext.java:5 94)
at org.jnp.interfa ces.NamingConte xt.lookup(Namin gContext.java:5 87)
at javax.naming.In itialContext.lo okup(InitialCon text.java:351)
at
com.cm.common.u til.jndi.MultiJ ndiLookup.getRe moteObjectStub( MultiJndiLookup .java:
377)
at
com.cm.common.u til.jndi.MultiJ ndiLookup.getRe moteObjectRef(M ultiJndiLookup. java:
130)
at
com.cm.common.u til.jndi.JndiLo okup.getRemoteO bjectRef(JndiLo okup.java:
88)
at
com.cm.system.S ystemInfoTopicM anager.init(Sys temInfoTopicMan ager.java:
91)
at
com.cm.system.S ystemInfoTopicM anager.reconnec t(SystemInfoTop icManager.java:
181)
at
com.m.system.Sy stemInfoTopicMa nager.onExcepti on(SystemInfoTo picManager.java :
216)
at org.jboss.mq.Co nnection
$ExceptionListe nerRunnable.run (Connection.jav a:1348)
at java.lang.Threa d.run(Thread.ja va:595)
Caused by:
at org.jnp.interfa ces.NamingConte xt.getServer(Na mingContext.jav a:269)
at org.jnp.interfa ces.NamingConte xt.checkRef(Nam ingContext.java :1385)
.... 11
2008-10-20 14:59:49,800
Unix diff gives extra output like
1,38c1,2
< 2008-10-20 15:00:09,890 WARN [trans2@D-CM-TRLOAD04:***:** *:***]
[ExceptionListen er Connection@
323[token=Connectio nToken:ID:93/1003454235 rcvstate=STARTE D]]
com.cm.system.S ystemInfoTopicM anager - Jms server not reachable..it
may be down. Deatils:Could not obtain
connection to any of these urls:
172.16.70.1:110 0,172.16.70.2:1 100,172.16.70.3 :1100,172.16.70 .4:1
100,172.16.70.5 :1100
I like to generate a 3rd file after comparing 2 files with format like
the other 2 files but containing only the difference between 1st and
2nd files.
ie
suppose the file contains
file1 file2
2008-10-20 15:00:06,113 ... 2008-10-20
15:00:06,113 ...
2008-10-20 15:00:06,113 ... 2008-10-20
15:00:06,113
2008-10-20 14:59:48,828 ...
2008-10-20 14:58:48,900 ...
javax.naming.Co mmunicationExce ption...
at org.jnp.interfa ces.NamingConte xt.ch...
I'm hoping to get in file3
2008-10-20 14:59:48,828 ...plus rest of line
2008-10-20 14:58:48,900 ...plus rest of line
I suppose I also need to read in the 1 field of the timestamp and
convert time to unix time to compare and then convert that unix time
to this timestamp format.
It looks like filecmp.cmp isn't enough to cope with my requirements
cuz it only gives a boolean value of 0 or 1,
not the actual print out of the differences between 2 files into a new
file.
Can this be done with Python quickly ?
Could someone be kind enough to show me steps to accomplish this ?
Any help is appreciated.
I have 2 log files, each with a timestamp on the first 2 fields.
However, when I do a
awk '/ / {print $1,$2}' logs/x.log
on a log file,
it is complicated by the fact that I also get other non timestamp
column,
2008-10-20 15:00:06,113
2008-10-20 15:00:06,113
2008-10-20 14:59:48,828
javax.naming.Co mmunicationExce ption: Could
at org.jnp.interfa ces.NamingConte xt.checkRef(Nam ingContext.java :1414)
at org.jnp.interfa ces.NamingConte xt.lookup(Namin gContext.java:5 94)
at org.jnp.interfa ces.NamingConte xt.lookup(Namin gContext.java:5 87)
at javax.naming.In itialContext.lo okup(InitialCon text.java:351)
at
com.cm.common.u til.jndi.MultiJ ndiLookup.getRe moteObjectStub( MultiJndiLookup .java:
377)
at
com.cm.common.u til.jndi.MultiJ ndiLookup.getRe moteObjectRef(M ultiJndiLookup. java:
130)
at
com.cm.common.u til.jndi.JndiLo okup.getRemoteO bjectRef(JndiLo okup.java:
88)
at
com.cm.system.S ystemInfoTopicM anager.init(Sys temInfoTopicMan ager.java:
91)
at
com.cm.system.S ystemInfoTopicM anager.reconnec t(SystemInfoTop icManager.java:
181)
at
com.m.system.Sy stemInfoTopicMa nager.onExcepti on(SystemInfoTo picManager.java :
216)
at org.jboss.mq.Co nnection
$ExceptionListe nerRunnable.run (Connection.jav a:1348)
at java.lang.Threa d.run(Thread.ja va:595)
Caused by:
at org.jnp.interfa ces.NamingConte xt.getServer(Na mingContext.jav a:269)
at org.jnp.interfa ces.NamingConte xt.checkRef(Nam ingContext.java :1385)
.... 11
2008-10-20 14:59:49,800
Unix diff gives extra output like
1,38c1,2
< 2008-10-20 15:00:09,890 WARN [trans2@D-CM-TRLOAD04:***:** *:***]
[ExceptionListen er Connection@
323[token=Connectio nToken:ID:93/1003454235 rcvstate=STARTE D]]
com.cm.system.S ystemInfoTopicM anager - Jms server not reachable..it
may be down. Deatils:Could not obtain
connection to any of these urls:
172.16.70.1:110 0,172.16.70.2:1 100,172.16.70.3 :1100,172.16.70 .4:1
100,172.16.70.5 :1100
I like to generate a 3rd file after comparing 2 files with format like
the other 2 files but containing only the difference between 1st and
2nd files.
ie
suppose the file contains
file1 file2
2008-10-20 15:00:06,113 ... 2008-10-20
15:00:06,113 ...
2008-10-20 15:00:06,113 ... 2008-10-20
15:00:06,113
2008-10-20 14:59:48,828 ...
2008-10-20 14:58:48,900 ...
javax.naming.Co mmunicationExce ption...
at org.jnp.interfa ces.NamingConte xt.ch...
I'm hoping to get in file3
2008-10-20 14:59:48,828 ...plus rest of line
2008-10-20 14:58:48,900 ...plus rest of line
I suppose I also need to read in the 1 field of the timestamp and
convert time to unix time to compare and then convert that unix time
to this timestamp format.
It looks like filecmp.cmp isn't enough to cope with my requirements
cuz it only gives a boolean value of 0 or 1,
not the actual print out of the differences between 2 files into a new
file.
Can this be done with Python quickly ?
Could someone be kind enough to show me steps to accomplish this ?
Any help is appreciated.