diff (1) --- isolate differences between two files 02/23/82 _U_s_a_g_e diff [-{b | c | d | r | s | v}] [ []] _D_e_s_c_r_i_p_t_i_o_n 'Diff' compares the contents of two files and reports on the differences between them. The default behavior is to describe the insert, delete, and change operations that must be performed on to convert its contents into those of . Both file name arguments are optional; if the second is omitted, the first standard input is used for ; if neither argument appears, the first and second standard input are used for and respectively. The options currently available are: -b Perform a word-for-word binary comparison. 'Diff' will compare corresponding words of the two input files; if any differences are found, or if one file is shorter than the other, 'diff' prints the message "different" and exits. If the files are the same, 'diff' produces no output. When the "-v" option (see below) is specified, 'diff' prints an octal representation of the words that differ along with their offset from the beginning of the file, and notifies the user if one file is shorter than the other. -c Perform a simple line-by-line comparison. 'Diff' will compare successive lines of the input files; if any corresponding lines differ, or if one file is shorter than the other, 'diff' prints the message "different" and exits. If the files are the same, 'diff' produces no output. When the "-v" option (see below) is specified, 'diff' prints the lines that differ along with their line num- ber in the input file, and notifies the user if one file is shorter than the other. -d List the "differences" between the two files, by highlighting the insertions, deletions, and changes that will convert into . This is the default option. If the "verbose" option "-v" (see below) is specified, unchanged text will also be listed. -r Insert text formatter requests to mark the with revision bars and deletion asterisks. This option is particularly diff (1) - 1 - diff (1) diff (1) --- isolate differences between two files 02/23/82 useful for maintenance of large documents, like Subsystem Reference Manuals. -s Output a "script" of commands for the text editor 'ed' that will convert into . This is handy for preparing updates to large programs or data files, since generally the volume of changes required will be much smaller than the new text in its entirety. -v Make output "verbose". This option applies to the "-b", "-c" and "-d" options discussed above. If not selected, 'diff' produces "concise" output; if selected, 'diff' produces more verbiage. _E_x_a_m_p_l_e_s diff myfile1 myfile2 diff rf.r nrf.r | pg diff -b /ca/bin/rp /cb/bin/rp diff -c afile maybe_the_same_file diff -v rf.r nrf.r | sp diff -r old_manual.fmt new_manual.fmt | fmt diff -s old new >>update_old_to_new _M_e_s_s_a_g_e_s ": can't open" if either or is not readable. "Usage: diff ..." for illegal options. _B_u_g_s The algorithm used has one quirk: a line or a block of lines which is not unique within a file will be labeled as an insertion (deletion) if its immediately adjacent neigh- bors both above and below are labeled as insertions (deletions). Fails on very large files (> 10000 lines) when using the "-d" option. _S_e_e _A_l_s_o common (1), Heckel, P., "A Technique for Isolating Differences Between Files", _C_o_m_m_u_n_i_c_a_t_i_o_n_s _o_f _t_h_e _A_C_M, vol 21, no 4 (April 1978), 264-268. diff (1) - 2 - diff (1)