Linux Command--diff command

Source: Internet
Author: User
Tags diff

The diff command compares two files and folders, and if you compare two files, two files are compared by line, and if you compare the directories, diff compares the files with the same name under two files, lists the different binaries, common subdirectories, and files that appear only in one directory.

Example 1 where 1c1 represents the first row, and C means that change,a means that add,d represents the delete

$ diff test1 test21c1< 123---> sdf3c3< 3432---> 2315c5< ADFS---> sadf7c7< ewr---


The example 2-y indicates that 2 files are compared side-by, followed by the-W to indicate the width of the specified column.

| Indicates that the contents of the front and back 2 files are different

"<" indicates that the following file is 1 lines less than the previous file

">" indicates that the following file has 1 lines more than the previous file

Diff test1 test2-y123 |sdf3432 |231adfs |sadfewr |2qwreqw

Example 3-C indicates a vertical comparison of 2 files

The "+" comparison of the latter of the files is more than the previous line

"-" compares the latter of the file with a smaller line than the previous

“! "Compare files with two different lines

Diff test1 test2-c*** test12015-09-07 00:05:39.000000000 +0800---test22015-09-07 00:05:54.000000000 +0800************ 1,7 ****! 123! 3432! adfs! EWR---1,7----! sdf! 231! sadf! 2qwreqw

Example 4-u represents a standard comparison,---represents the first file, + + + represents the second file, where the @@ 部分 indicates that the first file starts with 1-7 lines, and the second file starts with 1-7 lines

Diff test1 test2-u---test12015-09-07 00:05:39.000000000 +0800+++ test22015-09-07 00:05:54.000000000 +0800@@ -1,7 +1,7 @ @-123+sdf-3432+231-adfs+sadf-ewr+2qwreqw

Example 5 diff can also be used to compare 2 folders

Diff Test Test3only in test3:. Ds_storeonly in Test:test1only in Test3:test2only in Test3:test4

Example 6 to output a patch file

Diff-run test1 test2 >testpatch.log

Example 7 using patch files

Cat TEST11233432ADFSEWR
Patch test1 testpatch.logpatching file test1
Cat TEST1SDF231SADF2QWREQW

Reference documents

Http://www.cnblogs.com/peida/archive/2012/12/12/2814048.html


Linux Command--diff command

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.