Skip to content
EntityQ300901· pop 28· linked from 302 articles

diff is a shell command that compares the content of files and reports differences. The term diff is also used to identify the output of the command and is used as a verb for running the command. To diff files, one runs diff to create a diff.

Key facts

Software.name
diff
Software.title
diff
Software.author
Douglas McIlroy(AT&T Bell Laboratories)
Software.developer
Various open-source and commercial developers
Software.programming language
C
Software.operating system
Unix, Unix-like, V, Plan 9, Inferno
Software.platform
Cross-platform
Software.genre
Command
Software.license
Plan 9: MIT License

via Wikipedia infobox

Described at

The diff utility shall compare the contents of file1 and file2 and write to standard output a list of changes necessary to convert file1 into file2 . This list should be minimal. No output shall be produced if the files are identical. Produce output in a form that provides three lines of copied context. Apply diff recursively to files and directories of the same name when file1 and file2 are both directories. The diff utility shall detect infinite loops; that is, entering a previously visited directory that is an ancestor of the last file encountered. When it detects an infinite loop, diff shall write a diagnostic message to standard error and shall either recover its position in the hierarchy or terminate. Produce output in a form that provides three lines of unified context. If both file1 and file2 are directories, diff shall not compare block special files, character special files, or FIFO special files to any files and shall not compare regular files to directories. Further details are as specified in Diff Directory Comparison Format . The behavior of diff on other file types is implementation-defined when found in directories. The standard input shall be used only if one of the file1 or file2 operands references standard input. See the INPUT FILES section. Provide a default value for the internationalization variables that are unset or null. (See XBD Internationalization Variables for the precedence of internationalization variables used to determine the values of locale categories.) If set to a non-empty string value, override the values of all the other internationalization variables. Determine the locale for the interpretation of sequences of bytes of text data as characters (for example, single-byte as opposed to multi-byte characters in arguments and input files). Determine the locale that should be used to affect the format and contents of diagnostic messages written to standard error and informative messages written to standard output. Determine the locale for affecting the format of file timestamps written with the -C and -c options. [XSI) ] ![[Option Start]]( Determine the location of message catalogs for the processing of LC MESSAGES. ![[Option End]]( If both file1 and file2 are directories, the following output formats shall be used. For each file common to the two directories, if the two files are not to be compared: if the two files have the same device ID and file serial number, or are both block special files that refer to the same device, or are both character special files that refer to the same device, in the POSIX locale the output format is unspecified. Otherwise, in the POSIX locale an unspecified format shall be used that contains the pathnames of the two files. For each file common to the two directories, if the files are compared and are identical, no output shall be written. If the two files differ, the following format is written: All directory pathnames listed in this section shall be relative to the original command line arguments. All other names of files listed in this section shall be filenames (pathname components). In the POSIX locale, if one or both of the files being compared are not text files, it is implementation-defined whether diff uses the binary file output format or the other formats as specified below. The binary file output format shall contain the pathnames of two files being compared and the string "differ". If both files being compared are text files, depending on the options specified, one of the following formats shall be used to write the differences. 3. The form used for ranges of line numbers is -separated, rather than -separated. With the -c or -C option, the output format shall consist of affected lines along with surrounding lines of context. The affected lines shall show which ones need to be deleted or changed in file1 , and those added from file2 . With the -c option, three lines of context, if available, shall be written before and after the a

Excerpt from a page describing this subject · 28,166 chars · not written by Vinony

Article · Svenska

Diff är ett begrepp som används inom versionskontroll under exempelvis mjukvaruutveckling och används till exempel i CVS och Apache Subversion. Dessa system baserar sig på att källkoden för ett mjukvaruprojekt finns samlad på ett ställe, till exempel på en online-server. Alla utvecklare inom projektet kan närsomhelst ladda hem den senaste källkoden från denna server och redigera den självständigt (till skillnad från så kallade där källkoden på servern låses när någon laddar hem den). När utvecklare laddar upp den källkod som de redigerat till servern, används diff till att jämföra den redigerade källkoden med originalet. Då kombineras de nya ändringarna (merge) och det kan visas en sammanfattning på jämförelsen. Om två utvecklare har redigerat samma delar av originalfilen men på olika sätt, så kan den förste ladda upp sin version utan problem. När den andre så försöker ladda upp sina ändringar, råkar han ut för en så kallade konflikt, därför att systemet inte intellektuellt kan avgöra hur de nyaste ändringarna skall kombineras med de föregående ändringarna. Då används även diff för att grafiskt visa den senare utvecklaren var konflikten uppstår och vilka ändringar den föregående utvecklaren har gjort i originalet. Med hjälp av detta måste den senare utvecklaren manuellt redigera om sin kod så att allt fungerar planenligt med den förste utvecklarens idéer.

Abstract from DBpedia / Wikipedia · CC BY-SA

Diff · Vinony