DIFF command
The functionality of this command compares two text files, listing the differences. It completes more complex checks than the Comm command. It performs system checks for the files given and displays all different lines in two files, and no files are required in advance.
Syntax: DIFF [Option] file1 file2
Description: This command tells the user that in order to make the two files File1 and File2, which rows need to be modified. If "-" means File1 or Fiie2, the standard input is indicated. If File1 or File2 is a directory, DIFF will compare the same name file in this directory.
For example: DIFF / USR / XU Mine
Compare the file in the directory / usr / xu named Mine with the Mine file in the current directory.
It is usually output from the following form:
N1 a n3, n4
N1, N2 D N3
N1, N2 C N3, N4 These rows Similar to the ED command converts Filel to file2. The line numbers (N1, N2) before the letters (A, D, and C) are for File1, and the line numbers (N3, N4) behind it are for FILE2. Letters A, D and C indicate additional, delete, and modify operations, respectively.
After each line of the above form, followed by several rows that are affected, with the "<" of the leader belongs to the first file, and the line of ">" is a second file.
DIFF can distinguish between blocks and character device files and FIFO (pipe files), which will not compare them with ordinary files.
If File1 and File2 are directory, DIFF will generate a lot of information.
If there is only one file in a directory, a message is generated, indicating the directory path name and the file names.
The meaning of the DIFF option is as follows:
- b ignore the space of the row, and one or more spaces in the string are considered equal.
If How are you and how are you are treated as the same string.
- C uses the contextual output format (provide three-line context).
- C N uses the context output format (providing N-line context).
- E Produces a legal ED script as an output.
- R When File1 and File2 are directory, recursively acts on each file and directory.
For example, the content of the file ml.c is (the left line number is intended to add, in order to front and rear comparison):
1 main ()
{
Printf ("Hello! \N");
}
5 files M2.c is:
1 main ()
2 {
3 INT N, M;
4 n = 10;
5 Printf ("% D n", m = n * 10);
6}
input the command:
$ DIFF m1.c m2.c
Display on the screen:
3, 5 c 3, 6
Printf ("Hello! \N");
}
<5
> 3
INT N, M;
> 4 n = 10;
> 5 Printf ("% D n", m = n * 10);
> 6}
Indicates that two files are the same after the 3 to 5 lines of the file M1.c into M2.c.