Use the diff command of linux to compare file differences
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!