TrumanWong

diffstat

A bar chart showing the output of the diff command

Supplementary instructions

diffstat command is used to display the histogram of the diff command output information and to display the different statistical information of the diff command comparing two files. Users can also directly use | to send the results output by the diff command directly to the diffstat command for display of statistical results. When using this command, if the file or subdirectory being compared is not in the current directory, its full path should be used.

grammar

diffstat(options)(parameters)

Options

-n<file name length>: Specify the file name length. The specified length must be greater than or equal to the longest file name among all files;
-p <file name length>: The same as the -n parameter, but the <file name length> here includes the path of the file;
-w: Specify the width of the field to be output;
-v: Display version information.

Parameters

File: Specify the file containing the output information of the diff command.

Example

Use the diff command to compare the files "testf.txt" with the same name in the directories "test1" and "test2". Then use the diffstat command to display statistics on the results, enter the following command:

diff test1 test2 | diffstat #Statistics display of comparison results

Note: Using this command can very conveniently realize the statistical display function.

To view the contents of the file, users can view it through the cat command. The specific operations are as follows:

cat test1/testf.txt #View the contents of test1/testf
abc
def
ghi
jkj
mno
pqr
stu
vws

cat test2/testf.txt #View the contents of test2/testf
abc
def
ghi
jkj
mno

From the file content display above, you can see the difference in the contents of the two files. Now run the command just now to statistically display the results of the file comparison. The results are as follows:

testfile | 2 +- #Statistical information output display
1 file changed, 1 insertion(+), 1 deletion(-)