473,647 Members | 3,347 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Compare Files and Cat File Difference Question

zw
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.
Oct 21 '08 #1
0 1652

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
5117
by: Nicolas Fleury | last post by:
Hi everyone, Is there a way to compare recursively two objects (compare their members recursively)? I'm only interested in equality or non-equality (no need for lower-than...). Thx and Regards, Nicolas
1
2114
by: jyoti | last post by:
I am new in asp. I have two html files. I like to write code to compare those two files. I like to show the difference as highlighted area. Example: File 1 contains: <html><body> Compare Test</body></html> File 2 contains: <html><body> Compare Test modyfied</body></html> I like to make either the word "modyfied" highlighted or
3
5803
by: jyoti | last post by:
Hi there, I am trying to compare two strings and get the differenc in vbscript. Example: Str1="This is a test text" Str2="This is a fine test text but a little long" I like to compare str1 with str2 and get the difference. Above example the difference will be "fine" and "but a little long" How do I do that? A sample code would be apprciable.
2
621
by: RitaG | last post by:
Hi. In a VB.Net program I use File.Copy to copy some zipped (and text) files from one server to another. I'm required by management to do a file compare after the copy has completed. Is the File.Copy sufficient and it will error out if there's a problem or do I need to do a file compare to make sure nothing went wrong in the copy? If I do need to do a file comapre I was thinking about shelling out and running a bat file to use the Dos...
5
10055
by: drabee | last post by:
Please help 2 things: 1-I need c# code to compare 2 audio files .or any other .net code 2-code to receive bluetooth file from mobile and save it using .net code
6
6834
by: yinglcs | last post by:
Hi, i have 2 files which are different (1 line difference): $ diff groupresult20070226190027.xml groupresult20070226190027-2.xml 5c5 < x:22 y:516 w:740 h:120 area: --- But when I use the cmp() function to compare 2 files, it return "1",
3
9581
by: super.raddish | last post by:
Greetings, I am relatively new to, what I would call, advanced XSLT/XPath and I am after some advice from those in the know. I am attempting to figure out a mechanism within XSLT to compare the difference between two source documents and output node-sets which are "different" (changed or new) to new XML files using xsl:result-document To describe the problem I have provided some example data below along with my a portion of my current...
8
2592
by: Perl Beginner | last post by:
I am new to Perl and new to this site. I have the same question that I keep seeing, but not finding an answer…why doesn’t the compare function work? I’ve been going at this for a while. My code is (I’m using ActviePerl 5.8.8 Build 822 on Microsoft WinXP): use File::Compare; if (compare("$file1" , "$file") == 0) { print REPORT_FILE "Pass - Files are the same\n"; } else {print REPORT_FILE "Fail - Files are different\n"};
12
5857
by: loial | last post by:
I have a requirement to compare 2 text files and write to a 3rd file only those lines that appear in the 2nd file but not in the 1st file. Rather than re-invent the wheel I am wondering if anyone has written anything already?
0
8275
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8210
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8645
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8371
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7209
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6126
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5580
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4095
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4209
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.