Binary files diff


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users Binary files diff
# 1  
Old 04-23-2012
MySQL 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.
# 2  
Old 04-23-2012
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.
# 3  
Old 04-24-2012
Binary files diff

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,
SureshSmilie
# 4  
Old 04-24-2012
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.
# 5  
Old 04-24-2012
Quote:
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.
# 6  
Old 04-24-2012
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"
Code:
what [filename goes here]

Another command is
Code:
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.
# 7  
Old 04-25-2012
Question Binary files diff

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?
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Diff 3 files, but diff only their 2nd column

Guys i have 3 files, but i want to compare and diff only the 2nd column path=`/home/whois/doms` for i in `cat domain.tx` do whois $i| sed -n '/Registry Registrant ID:/,/Registrant Email:/p' > $path/$i.registrant whois $i| sed -n '/Registry Admin ID:/,/Admin Email:/p' > $path/$i.admin... (10 Replies)
Discussion started by: kenshinhimura
10 Replies

2. Shell Programming and Scripting

Binary files

Hi All,Is there anyway I can conver the binary file to ascii. I don't know the binary file format. file command just lists this as "data" file and when I view it has a lot of non-printable characters.Can I write any command equivalent to wc -l to find out the number of rows in the file?Can I use... (4 Replies)
Discussion started by: rahulkav
4 Replies

3. Shell Programming and Scripting

diff bw two files

Hi All, I have two files which look as below File1 serial="1" name="abc" type="employee" field="IT" serial="2" name="cde" type="intern" field="Marketing" serial="3" name="pqr" type="contractor" field="IT" serial="4" name="xyz" type="employee" field="Sales" File2 serial="1"... (3 Replies)
Discussion started by: grajp002
3 Replies

4. Shell Programming and Scripting

diff of files

Hi, I have 2 files.I want to check if file1 is contained in file2. A.txt: ----- AAA BBB B.txt: ------ CCC AAA BBB DDD I want to check if A.txt is contained in B.txt. Can it be done using SED ? (12 Replies)
Discussion started by: giri_luck
12 Replies

5. Shell Programming and Scripting

Diff b/w 2 files

Hi Masters, I have two files named file1 and file2. Both the files contains the same contents with some difference in comments,space.But no content change. I tried to find the diff between the two files to make sure that contents are same. For that i tried diff -ibw file1 file2 But... (1 Reply)
Discussion started by: ecearund
1 Replies

6. Shell Programming and Scripting

Find duplicates from multuple files with 2 diff types of files

I need to compare 2 diff type of files and find out the duplicate after comparing each types of files: Type 1 file name is like: file1.abc (the extension abc could any 3 characters but I can narrow it down or hardcode for 10/15 combinations). The other file is file1.bcd01abc (the extension... (2 Replies)
Discussion started by: ricky007
2 Replies

7. Shell Programming and Scripting

search for files excluding binary files

Hi All, I need a solution on my following find command find ./.. -name '*.file' -print BTW This gives me the output as belows ./rtlsim/test/ADCONV0/infile/ad0_dagctst.file ./rtlsim/test/ADCONV0/user_command.file ./rtlsim/test/ADCONV0/simv.daidir/scsim.db.dir/scsim.db.file... (2 Replies)
Discussion started by: user_prady
2 Replies

8. UNIX for Dummies Questions & Answers

Binary Files

Here's the problem... I'm using a simulator on UNIX, and it requires a filename where bits are stored, it should read them out and do whatever with them at that point.. So what i'm trying to do is make a binary file on UNIX. On my PC i can use MSDEV, or any of my C++ compilers to generate a... (2 Replies)
Discussion started by: wcRandThor
2 Replies

9. Shell Programming and Scripting

diff 2 files; output diff's to 3rd file

Hello, I want to compare two files. All records in file 2 that are not in file 1 should be output to file 3. For example: file 1 123 1234 123456 file 2 123 2345 23456 file 3 should have 2345 23456 I have looked at diff, bdiff, cmp, comm, diff3 without any luck! (2 Replies)
Discussion started by: blt123
2 Replies

10. UNIX for Dummies Questions & Answers

Binary Files

Does any one know how to view a binary file as it is (in 1s and 0s) on unix environment? (1 Reply)
Discussion started by: devildivine
1 Replies
Login or Register to Ask a Question