How to use the Linux diffstat command

Source: Internet
Author: User

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:

  • -N

    <File name length> specifies the file name length. The specified length must be greater than or equal to the longest file name in all files.
  • -P

    The <file name length> is the same as the-n parameter, but the <file name length> here includes the file path.
  • -W specifies the width of the field when the output is made.

  • -V displays the version information.

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 (-)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.