The Linux diffstat command displays statistics based on the comparison results of diff.
Diffstat reads the output result of diff, and then counts the metering of different files, such as insertion, deletion, and modification.
Syntax
Diff [-wV] [-n <file name length>] [-p <file name length>]
Parameters:
Instance
You can also directly use "|" to send the result output by the diff command to the diffstat command for statistics display.
When using this command, if the file or subdirectory to be compared is not in the current directory, the full path should be used.
Use the diff command to compare the testf.txt file in the "test1" and "test2" directories. Then use the diffstat command to display the result. Enter the following command:
$ Diff test1 test2 | diffstat # statistical display of comparison results
Note: You can use this command to conveniently display statistics.
You can run the command "cat" to view the content in the file. The specific operations are as follows:
$ Cat test1/testf.txt # view the content of test1/testf abcdefghi jkl mno pqr stu vws $ cat test2/testf.txt # view the content of test2/testf abcdefghi jkl mno
The content of the preceding file shows the differences between the two files. Now run the command and compare the results of the file. The results are as follows:
Testfile | 2 +-#1 file changed, 1 insertion (+), 1 deletion (-)