Binary files diff

Hi

I am very happy to joined this group!!!

I need your suggestion for get it resolved my issue.

I have two class files both class files are same, there is no diff in both two files. Both 2 files were compiled in Linux environment with different type of OS.
When i am using diff command, the output came as Binary files a.class and b.class differ.

But there is no differ in file content. Both are similar only, but when i am using cksum or diff command, it is showing diff.
I don't know, why the output of command is came as wrongly.

Please advise me, how to get exact diff report.

This is nothing unusal. There will be differences in the Libraries which were used to compile the programs. Just compare the program Source Code, not the runnable binary image.
In future, please post what computer language you are using, what Operating Systems are relevant, and what Shell you use.

Hi

Thanks for your reply.

I don't want to compare with Libraries, i want to compare only class files alone.
Even though i have used different Libraries in my Linux server compilation environment, my class files are same, there is no diff in my class files.
But if i compare along with build server Libraries, it is not matching. It is showing difference.

if i compare along with Libraries, i won't get exact diff report.
Please suggest me, how i can compare only my class files alone using diff command.

OS: RHEL4-U3-i386-AS-20060613
Shell: /bin/sh

Regards,
Suresh:p

The diff command is for comparing text files. It is not suitable for comparing binary programs.
Btw. I don't know what a "class file" is.

I assume the OP is talking about Java class files.

If you want to check that the two class files are idential, check that the javap -c (the Java disassembler) output is identical for the two files.

Here is why what you want does not make sense.

Suppose you compile a simple 3 line program, say C. Or. It can be any language, the output can be bytecode or a compiled image. Or an archive.

Compilers/tools/etc stick extra junk in the compiled code, jar does that, too. They are symbolic strings that identify the jar/ar/compiler/linker/interpreter/ant/eclipse, whatever.

To see what I mean, try these commands on each of your "class files"

what [filename goes here]

Another command is

strings [filename goes here]

You will find extra "where did that come from?" strings in there. The ONLY time you will get identical "class files" is from the exact same machine using the exact same set of tools on exactly the same code. For some tools it has to be done at the exact same UNIX time, because a few tools may embed time strings, too. Example: HPUX ld & GNU ld, link edit tools. Anything else and all bets are off.

Hi

Thanks for your response.

Actually what i am trying to achieve is, when I compare two java class files(both files are same), which has been compiled in two different version of Linux OS, it should be consider only java class files content alone.
When I compare two java class files, it should be match. But when i am running �diff a.class (Java class file) b.class (java class file)� command, it is showing binary file contain diff.

I have compared both two java class files internally, there is no difference.
In this case, can anyone advice me, how I can get diff report between java class files.

I have around 1000 class files. Is there any way to get diff report b/w class files?

It doesn't work that way.

When you compile a program, it doesn't just dump down everything you do in text in some raw, binary format. The compiler must actually translate, and makes many complicated decisions about which is the most optimal way to do something.

Slightly different systems, environments, compilers, compiler options, and source code can all cause the code generated to be radically different.

In short, the change from source code to binary program is rather irreversible. The code doesn't resemble the input anymore, there's not much meaningful left to compare.

can any one tell the difference bte binary file and normal file in unix

Please avoid hijacking 4-month-old threads.
The terms "basic file" does not appear in unix (or any other Operating System which I can think of). The usual distinction is "text file" compared with "binary file". There are many types of "binary file".
The very basic answer is to use the unix file command.
e.g.

file filename

Try it and see if it gives the result you require.

hi this is krish
1.can any one tell how to know the background job is done
2.what is trace root
3.ip config mean what exactly it is ?
4.how to know if other user is using our login id and the process running on our id?
5 In top command what the load 3 values represent and how to know load is more or less?

Hi krish,Please open a new thread for your clari or queries. Dont use others thread that will make a lot of confusion. If you do the same again and again, moderators will punish you.Mods what are you doing guys?Cheers,Ranga:-)

@nvramakrishna
Please open a new thread in the Homework Forum according to the Homework rules, and take some time to transcribe the questions accurately and to show your own effort.

e.g.
"trace root" should surely be "traceroute".
"ip config" should surely be "ipconfig".

Moderator comments were removed during original forum migration.