diffstat
Linux diffstat command syntax
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 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 perform statistical display of the results. Enter the following command:
$ diff test1 test2 | diffstat #進行比較結(jié)果的統(tǒng)計顯示
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的內(nèi)容 abc def ghi jkl mno pqr stu vws $ cat test2/testf.txt #查看test2/testf的內(nèi)容 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 +- #統(tǒng)計信息輸出顯示 1 file changed, 1 insertion(+), 1 deletion(-)