English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
The Linux diffstat command displays statistics based on the comparison results of diff.
diffstat reads the output of diff and then counts the differences in insertions, deletions, modifications, and other metrics.
diff [-wV][-n <filename length>][-p <filename length>]
Parameter:
Users can also directly use "|" to pass the output of the diff command to the diffstat command for statistical display.
When using this command, if the file or subdirectory to be compared is not in the current directory, then the complete path should be used.
Use the directory "test1" and "test2" under the same name file "testf.txt" use the diff command for comparison. Then use the diffstat command to display the statistical results, input the following command:
$ diff test1 test2 | diffstat #Display the statistical results of the comparison
Note: Using this command can very conveniently realize the function of statistical display.
To view the content of a file, users can view it by using the command "cat", as follows:
$ cat test1/testf.txt #View test1/Content of testf abc def ghi jkl mno pqr stu vws $ cat test2/testf.txt #View test2/Content of testf abc def ghi jkl mno
From the above file content display, it can be seen that the differences between the contents of the two files. Now let's run the command just now to display the statistical results of the file comparison, as follows:
testfile | 2 +- Display of statistical information 1 file changed, 1 insertion(+) 1 deletion(-)