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

Use the diff command of linux to compare file differences

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

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

This article mainly introduces the use of linux diff command to compare the differences of files, has a certain reference value, friends in need can refer to. Let's take a look at it with me.

Diff compares the similarities and differences of text files line by line. If you specify to compare directories, diff compares files with the same filename in the directory, but not their subdirectories.

Syntax format: diff [parameters] [directory]

Common parameters:

The-adiff preset only compares text files line by line-b does not check for differences in space characters-W specifies the column width-x does not compare the file or directory specified in the option-X you can save the file or directory type as a text file, and then specify this text file-y to display the similarities and differences of the file in a side-by-side manner in =-help view help information-left-column when using the-y parameter If one line of the two files is the same, the line is displayed only in the field on the left-suppress-common-lines shows only the differences when using the-y parameter

Reference example

Compare two files:

[root@linuxcool ~] # diff log2014.log log2013.log

Side-by-side format output:

[root@linuxcool] # diff log2014.log log2013.log-y-W 502013-012013-012013-02 2013-022014-03 | 2013-032013-042013-042013-052013-052013-062013-062013-072013-072013-07 | | 2013-082013-092013-092013-102013-102013-11-12 |

Note: "|" indicates that the contents of the two files are different, and "" indicates that the latter file has one more line of content than the previous file.

These are the details of using linux's diff command to compare the differences in files. Do you have anything to gain after reading it? If you want to know more about it, welcome to the industry information!

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

Servers

Wechat

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

12
Report