Help with file differences


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Help with file differences
# 1  
Old 12-10-2009
Help with file differences

I have two huge files in the size of 1gb. They are produced by similar processes and the expected thing is that they should match in size and contents. I have produced both the files with the processes and they seem to be off only by few bytes.

Size file name
1634502037 Transfer_delta_reservation_file.txt
1634501922 delta_transfer_file.txt

I tried to see the differences with the diff and sdiff but both of them are showing everything as different. I checked the files manually for couple of records and they seem to match exactly. I couldn't find out why there is this small difference in bytes and if so where are this extra bytes coming from. Is there a way or a program to just show the differences in the file and their line numbers. I did the diff after sorting them. Please help.
# 2  
Old 12-10-2009
diff(1) can be told to ignore differences with tabs (--ignore-tab-expansion), spaces (--ignore-space-change) or (--ignore-all-space) and also carriage returns (--strip-trailing-cr), i.e. any number of cpaces or tabs are treated as one space or tab respectively or any form of "whitespace" is treated as equivalent and the presence of cr+lf or just lf is treated as erquivalent, all these are worth a try. Other parameters worth trying are --text and --speed-large-files.

Otherwise you can use od(1) to look at what is really in each line in ASCII, e.g. run:
Code:
$ head -10 <file> | od -bc

against both files (looking at only the first 10 lines of each) and see if that may give you a clue as why diff thinks every line is different.
# 3  
Old 12-10-2009
Code:
cmp -l fiel1 file2

will show where the files start to differ. Pay attention to the values differed to see if there is a shift or change of values. Add -b to cmp option if you have it:

Code:
$ cmp -bl <(echo abcdefgh) <(echo abcDefgh)
                  4 144 d    104 D
$ cmp -bl <(echo abcdefgh) <(echo abcefgh)
                  4 144 d    145 e
                  5 145 e    146 f
                  6 146 f    147 g
                  7 147 g    150 h
                  8 150 h     12 ^J

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

ksh / AIX - Differences between lists to a text file

This seems pretty simple, but I cant figure it out. I get stumped on the simple things. I am running two commands 1) take a listing a directory of files, and filter out the doc_name (which is in a series of extracted files), and place it in a file. ls -l | awk '{print $9}' | grep... (5 Replies)
Discussion started by: jeffs42885
5 Replies

2. Shell Programming and Scripting

awk to find differences between two file

I am trying to find the differences between the two sorted, tab separated, attached files. Thank you :). In update2 there are 52,058 lines and in current2 there are 52,197 so 139 differences should result. However, awk 'FNR==NR{a;next}!($0 in a)' update2 current2 > out2comm -1 -3... (2 Replies)
Discussion started by: cmccabe
2 Replies

3. UNIX for Dummies Questions & Answers

Compare and merging the differences in text file

Hi i have gone through some sdiff command it shows the differences side by side and its really awesome file 1: this tool is for checking the differ merging with flower pots documentation file 2: this t ool is for checking the differ mergin g with flower pots documentation ... (27 Replies)
Discussion started by: rakeshkumar
27 Replies

4. Shell Programming and Scripting

{} and ( ) differences

Can u tell the diff between the 1) $a and ${a} 2)] and ( ) 3)" " and ' ' , ` ` 4) 'a' , "a", please explain with simple example (1 Reply)
Discussion started by: mrbinoy
1 Replies

5. Programming

Symbol differences in STLport library and application object file

Hello, I compiled the object file of a binary and i could see the symbol , "void*std::__node_alloc<1,0>::_M_allocate(unsigned)", this is actually present as "void*std::__node_alloc<true,0>::_M_allocate(unsigned)" in the libstlport4.so.1 . This has been verified with "nm -C " command Please... (4 Replies)
Discussion started by: shafi2all
4 Replies

6. Shell Programming and Scripting

Differences between 2 Flat Files and process the differences

Hi Hope you are having a great weeknd !! I had a question and need your expertise for this : I have 2 files File1 & File2(of same structure) which I need to compare on some columns. I need to find the values which are there in File2 but not in File 1 and put the Differences in another file... (5 Replies)
Discussion started by: newbie_8398
5 Replies

7. Shell Programming and Scripting

Unique File Differences

I have the 2 files File 1 ABC,1239800 BCED,890000 ABCKJK,66767 File 2 GUHJC,1239800 ABC,1239800 TYIO,5636 The thing is the no of values in file can exceed example ABC,1239800,4545465,AHHAH so i need to find those values in file 1 which do not match in File 2 so i should get... (7 Replies)
Discussion started by: dinjo_jo
7 Replies

8. Shell Programming and Scripting

Compare File Differences in different directories

Hello, I am new to scripting and have been trying to compare two different directories, but with all the same file names in each directory for file changes. I have been doing it in baby steps and have been doing pretty good, but I have hit a few snags. Test 1 and Test 2 work great, but my... (4 Replies)
Discussion started by: dmaday
4 Replies

9. Shell Programming and Scripting

Comparing files columnwise and print the differences in third file

Hello Everybody!!!!!!!!! Request you to help me with the below mentioned issue: I have 2 files say, File 1: a|4|7 b|3|2 c|8|8 d|8|9 File 2: a|4|6 b|2|2 c|8|8 d|9|8 The third file(output file) should have: Data mismatch in row 1 column 3 Data mismatch in row 2 coumn 2 Data... (3 Replies)
Discussion started by: abhijeet1409
3 Replies

10. Shell Programming and Scripting

comparing file content differences

I need to write a script to find out if there are any .c files created/removed from the last time i monitored the files available. i first created a file to contain all the .c files available on the system. (ls *.c > file1) I created another file using the same command. I used the comm file1... (4 Replies)
Discussion started by: RianTan
4 Replies
Login or Register to Ask a Question