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.
via Wikipedia infobox
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
~21 min read
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.
Typically, the command is used to compare text files, but it does support comparing binary files. If one of the input files contains non-textual data, then the command defaults to brief-mode in which it reports only a summary indication of whether the files differ. With the option, it always reports line-based differences, but the output may be difficult to understand since binary data is generally not structured in lines like text is.
Excerpt from a page describing this subject · 28,166 chars · not written by Vinony
via Wikidata · CC0
via Wikidata sitelinks · CC0
Discovered by embedding cosine similarity (sentence-transformers MiniLM, 384-dim).