Linux diffstat command
Translation results:
diffstat
Linux diffstat commandsyntax
Function: The diffstat command displays statistics based on the comparison results of diff. diffstat reads the output results of diff, and then counts the insertion, deletion, modification and other differences of each file.
Syntax: diff [-wV][-n <file name length>][-p <file name length>]
Linux diffstat commandexample
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 perform statistical display of the results. Enter the following command:
$ diff test1 test2 | diffstat #进行比较结果的统计显示
Note: Using this command can very conveniently realize the statistical display function.
To view the contents of the file, the user can view it through the command "cat". The specific operation is as follows:
$ cat test1/testf.txt #查看test1/testf的内容 abc def ghi jkl mno pqr stu vws $ cat test2/testf.txt #查看test2/testf的内容 abc def ghi jkl mno
From the above file content display, you can see the contents of the two files difference. Now run the command just now to statistically display the results of the file comparison. The results are as follows:
testfile | 2 +- #统计信息输出显示 1 file changed, 1 insertion(+), 1 deletion(-)