diff output is it correct??


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting diff output is it correct??
# 1  
Old 03-18-2010
Question diff output is it correct??

I'm asking for explanation about the output of the diff format when i compare the two files f1 and f2:

Code:
root@host1 # cat f1
205226
205237
205250
205255
205262
205274
205307
205403
205464
205477
205500
205520
205626
205759
205766
205776
205861
root@host1 # cat f2
204929
205018
205039
205237
205250
205255
205262
205403
205464
205477
205500
205626
205759
205766
205776
205936
205970
205975
205979
205983
205984


when i made a diff command i got the following:

Code:
root@host1 # diff f1 f2
1c1,3
< 205226
---
> 204929
> 205018
> 205039
6,8c8
< 205274
< 205307
< 205403
---
> 205403
12d11
< 205520
17c16,21
< 205861
---
> 205936
> 205970
> 205975
> 205979
> 205983
> 205984



my question is:

why output indicate the following:

6,8c8
< 205274
< 205307
< 205403
---
> 205403

instead of issuing a delete 6,7d7
and then 8 and 8 in both sides will not be displayed because they are equal.


actually, i don't understand why the c flag is required since the d and a flags are available.
# 2  
Old 03-18-2010
I workout with this, for me its working, See the following output.

Code:
1c1,3
< 205226
---
> 204929
> 205018
> 205039
6,7d7
< 205274
< 205307
12d11
< 205520
17c16,21
< 205861
---
> 205936
> 205970
> 205975
> 205979
> 205983
> 205984

try with the following commands . grep -f file_one file_two, vimdiff, and comm, commands.
compare the result to diff.
# 3  
Old 03-18-2010
it worked with me too on a redhat os, the first one was executed from solaris 10.
also i've tried the comm command and it worked as i wanted.

curiosity is forcing me again to ask what is the reason for this? is it a bug? and does that affect creating the updated version of the original file using a batch?
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

awk output is not the correct count

The awk below runs and produces the following output on the file2. This is just an example of the format as the file is ~14MB. file1.txt is attached. I am trying to count the ids that match between the two files and out the ids that are missing. Thank you :). file2 970 NM_213590 ... (2 Replies)
Discussion started by: cmccabe
2 Replies

2. Shell Programming and Scripting

Now showing the correct output

Hello I am working on one script where I am trying to display all the directories which is inside the workspace but somehow it is giving me weird output and this is occurring only with one directory other also having the result.html file inside the directory. for i in `ls -1 | egrep -iv... (2 Replies)
Discussion started by: anuragpgtgerman
2 Replies

3. Shell Programming and Scripting

Output not in correct format - cd script

I have a script that looks like this: dirname2=/usr/tmp/filelist/*/* for dirname2 in /tmp/filelist/*/*; do (cd $dirname2/catalog ||echo "file does not exist" && echo "$dirname2" |cut -d '/' -f 7,8 && echo $i && ls -la |awk 'NR>3 {SUM += $5} END { print "Total number of kb " SUM }');done... (2 Replies)
Discussion started by: newbie2010
2 Replies

4. Shell Programming and Scripting

Html output in correct format

Hi, I am running two scripts as below. In Script 1 i am getting correct output in proper HTML format while in script 2 i am not getting output in mail and only html code is getting printed.I want to get the output of script 2. Please guide. 1.IFILE=/home/home01/Report.csv if #Checks... (7 Replies)
Discussion started by: Vivekit82
7 Replies

5. Shell Programming and Scripting

Help with diff output

I am running diff between two directories dir1 and dir2. diff --exclude --recursive --brief -b dir1 dir2 The output of the above command is Files dir1/java/abc/bcd/abc9991.java and dir2/java/abc/bcd/abc9991.java differ Files dir1/java/abc/bcd/abc9933.java and... (11 Replies)
Discussion started by: gaurav99
11 Replies

6. Shell Programming and Scripting

How to print the output in correct order?

Hi, while using following awk commend I’m getting confused, The output is not like as the row present in input files, can anyone explain and tell me how to print in the order like in input. value=$(awk 'FNR>1 && NR==FNR{a=$4;next} a{sum+=$4} END {for(i in sum){printf i"\t"sum/2"@@";}}'... (5 Replies)
Discussion started by: Shenbaga.d
5 Replies

7. Shell Programming and Scripting

Getting the correct identifier in the output file

Hi All I do have a file like this: 1 1 12 26 289 3.2e-027 GCGTATGGCGGC 2 12 26 215 6.7e+006 TTCCACCTTTTG 3 9 26 175 8.9e+016 GCGGTAACT 4 20 26 232 1.7e+013 TTTTTATTTTTTTTTTTTCC 5 ... (6 Replies)
Discussion started by: Lucky Ali
6 Replies

8. Shell Programming and Scripting

AWK not giving me correct output.

i have a line like this in my script IP=`get_IP <hostname> | awk '{ print $1 }' echo $IP the problem is get_IP <hostname> returns data formated as follows: ip 1.1.1.1 name server_name the code above returns 1.1.1.1 server_name and i just need the 1.1.1.1 I have tried to add "|... (5 Replies)
Discussion started by: mcdef
5 Replies

9. UNIX for Dummies Questions & Answers

diff output

I have two CSV files and I would like to create a third CSV file containing the differences between the two. I understand the diff command can be used to list differences between two files. My problem is that when I pipe the output into a third CSV file, the line numbers and other formatting... (3 Replies)
Discussion started by: paulp
3 Replies

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