United States-English |
|
|
HP-UX Reference > Ddiff(1)HP-UX 11i Version 3: February 2007 |
|
NAMEdiff — differential file and directory comparator SYNOPSISdiff [-C n] [-S name] [-lrs] [-bcefhintw] dir1 dir2 diff [-C n] [-S name] [-bcefhintw] file1 file2 diff [-D string] [-biw] file1 file2 DESCRIPTIONComparing DirectoriesIf both arguments are directories, diff sorts the contents of the directories by name, then runs the regular file diff algorithm (described below) on text files that have the same name in each directory but are different. Binary files that differ, common subdirectories, and files that appear in only one directory are listed. When comparing directories, the following options are recognized:
Comparing FilesWhen run on regular files, and when comparing text files that differ during directory comparison, diff tells what lines must be changed in the files to bring them into agreement. diff usually finds a smallest sufficient set of file differences. However, it can be misled by lines containing very few characters or by other situations. If neither file1 nor file2 is a directory, either can be specified as -, in which case the standard input is used. If file1 is a directory, a file in that directory whose filename is the same as the filename of file2 is used (and vice versa). There are several options for output format. The default output format contains lines resembling the following: n1 a n3,n4 n1,n2 d n3 n1,n2 c n3,n4 These lines resemble ed commands to convert file1 into file2. The numbers after the letters pertain to file2. In fact, by exchanging a for d and reading backwards one may ascertain equally how to convert file2 into file1. As in ed, identical pairs where n1=n2 or n3=n4 are abbreviated as a single number. Following each of these lines come all the lines that are affected in the first file flagged by <, then all the lines that are affected in the second file flagged by >. Except for -b, -w, -i, or -t which can be given with any of the others, the following options are mutually exclusive:
EXTERNAL INFLUENCESEnvironment VariablesLANG determines the locale to use for the locale categories when both LC_ALL and the corresponding environment variable (beginning with LC_) do not specify a locale. If LANG is not set or is set to the empty string, a default of "C" (see lang(5)) is used. LC_CTYPE determines the space characters for the diff command, and the interpretation of text within file as single- and/or multi-byte characters. LC_MESSAGES determines the language in which messages are displayed. If any internationalization variable contains an invalid setting, diff and diffh behave as if all internationalization variables are set to "C". See environ(5). RETURN VALUEUpon completion, diff returns with one of the following exit values:
EXAMPLESThe following command creates a script file script: diff -e x1 x2 >script w is added to the end of the script in order to save the file: echo w >> script The script file can then be used to create the file x2 from the file x1 using the editor ed in the following manner: ed x1 < script The following command produces the difference output with 2 lines of context information before and after the line that was different: diff -C2 x1 x2 The following command ignores all blanks and tabs and ignores uppercase-lowercase differences. diff -wi x1 x2 WARNINGSEditing scripts produced by the -e or -f option are naive about creating lines consisting of a single dot (.). When comparing directories with the -b, -w, or -i options specified, diff first compares the files in the same manner as cmp, then runs the diff algorithm if they are not equal. This may cause a small amount of spurious output if the files are identical except for insignificant blank strings or uppercase/lowercase differences. The default algorithm requires memory allocation of roughly six times the size of the file. If sufficient memory is not available for handling large files, the -h option or bdiff can be used (see bdiff(1)). With other options if sufficient memory is not available, then either the swap or maxdsiz values can be increased. When run on directories with the -r option, diff recursively descends sub-trees. When comparing deep multi-level directories, more memory may be required than is currently available on the system. The amount of memory required depends on the depth of recursion and the size of the files. SEE ALSObdiff(1), cmp(1), comm(1), diff3(1), diffmk(1), dircmp(1), ed(1), more(1), nroff(1), rcsdiff(1), sccsdiff(1), sdiff(1), terminfo(4). |
Printable version | ||
|