Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I have file1.txt

this is the original text  
line2  
line3  
line4  
happy hacking !  

and file2.txt

this is the original text  
line2  
line4  
happy hacking !  
GNU is not UNIX  

if I do: diff file1.txt file2.txt I get:

3d2  
< line3  
5a5  
> GNU is not UNIX  

How is the output generally interpreted? I think that < means removed but what do 3d2 or 5a5 mean?

If I do:

$ diff -u file1.txt file2.txt  
--- file1.txt        2013-07-06 17:44:59.180000000 +0200  
+++ file2.txt        2013-07-06 17:39:53.433000000 +0200  
@@ -1,5 +1,5 @@  
 this is the original text  
 line2  
-line3  
 line4  
 happy hacking !  
+GNU is not UNIX  

The results are clearer but what does @@ -1,5 +1,5 @@ mean?

share|improve this question

2 Answers 2

Summary:

Given a diff file1 file2, < means the line is missing in file2 and >means the line is missing in file1. The 3d2 and 5a5 can be ignored, they are commands for patch which is often used with diff.

Full Answer:

Many *nix utilities offer TeXinfo manuals as well as the simpler man pages. you can access these by running info command, for example info diff. In this case, the section your are interested in is:

2.4.2 Detailed Description of Normal Format


The normal output format consists of one or more hunks of differences; each hunk shows one area where the files differ. Normal format hunks look like this:

 CHANGE-COMMAND
 < FROM-FILE-LINE
 < FROM-FILE-LINE...
 ---
 > TO-FILE-LINE
 > TO-FILE-LINE...

There are three types of change commands. Each consists of a line number or comma-separated range of lines in the first file, a single character indicating the kind of change to make, and a line number or comma-separated range of lines in the second file. All line numbers are the original line numbers in each file. The types of change commands are:

`LaR'
     Add the lines in range R of the second file after line L of the
     first file.  For example, `8a12,15' means append lines 12-15 of
     file 2 after line 8 of file 1; or, if changing file 2 into file 1,
     delete lines 12-15 of file 2.

`FcT'
     Replace the lines in range F of the first file with lines in range
     T of the second file.  This is like a combined add and delete, but
     more compact.  For example, `5,7c8,10' means change lines 5-7 of
     file 1 to read as lines 8-10 of file 2; or, if changing file 2 into
     file 1, change lines 8-10 of file 2 to read as lines 5-7 of file 1.

`RdL'
     Delete the lines in range R from the first file; line L is where
     they would have appeared in the second file had they not been
share|improve this answer

You should read the fine (TeXinfo) manual, the section "`diff' Output Formats" has all info you need. (First form of output is 'Normal' diff, second form is 'Unified' diff.)

share|improve this answer
    
What is Texinfo manual? man? –  Jim Jul 6 '13 at 21:39
    
try info find. TeXinfo is gnu.org/software/texinfo –  sendmoreinfo Jul 7 '13 at 16:06

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.