Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use the common command diff in Linux

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

This article is to share with you about how to use the common command diff in Linux. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.

The Linux common command diffstat command is used to display the bar chart of the output information of the diff command, and to show the different statistical information of the diff command comparing the two files.

Syntax diff [- wV] [- n] [- p] argument:

-n specifies the length of the file name, which must be greater than or equal to the longest file name of all files.

The-p parameter is the same as the-n parameter, but here the path to the file is included.

-w specifies the width of the field on output.

-V displays version information.

The example compares the same name file "testf.txt" under the directory "test1" and "test2" using the diff command. Then use the diffstat command to statistically display the results, and enter the following command:

Diff test1 test2 | diffstat # for statistical display of comparison results Note: the statistical display function can be easily realized by using this command.

You can view the contents of the file by using the cat command, as shown below:

Cat test1/testf.txt # View the contents of test1/testf abc def ghi jkl mno pqr stu vws cat test2/testf.txt # View the contents of test2/testf abc def ghi jkl mno from the contents of the file above, you can see the difference between the contents of the two files. Now run the previous command to statistically display the results of the file comparison. The results are as follows:

Testfile | 2 +-# Statistical output shows 1 file changed, 1 insertion (+), 1 deletion (-) Thank you for reading! This is the end of the article on "how to use diff in Linux". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, you can share it for more people to see!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report