YouTip LogoYouTip

Linux Comm Diffstat

# Linux diffstat Command [![Image 3: Linux Command Manual](#) Linux Command Manual](#) The Linux diffstat command displays statistics based on the comparison results from diff. diffstat reads the output from diff and then calculates statistics for insertions, deletions, and modifications across the files. ### Syntax diff **Parameters**: * -n Specifies the filename length. The specified length must be greater than or equal to the longest filename among all files. * -p Same as the -n parameter, but here includes the file path. * -w Specifies the column width for output. * -V Displays version information. ### Example Users can also directly use "|" to pipe the output from the diff command to the diffstat command for statistical display. When using this command, if the files or subdirectories being compared are not in the current directory, their full paths should be used. Compare the file "testf.txt" with the same name in directories "test1" and "test2" using the diff command. Then use the diffstat command to statistically display the results. Enter the following command: $ diff test1 test2 | diffstat #Perform statistical display of comparison results Note: Using this command provides a very convenient way to implement statistical display functionality. To view the contents of the files, users can use the "cat" command. The specific operation is as follows: $ cat test1/testf.txt #View content of test1/testf abc def ghi jkl mno pqr stu vws $ cat test2/testf.txt #View content of test2/testf abc def ghi jkl mno From the file content displayed above, you can see the differences between the two files. Now run the previous command to statistically display the results of the file comparison. The result is as follows: testfile | 2 +- #Statistical information output display 1 file changed, 1 insertion(+), 1 deletion(-) [![Image 4: Linux Command Manual](#) Linux Command Manual](#)
← Linux Comm FileLinux Comm Diff β†’