26. Several common Linux Shell functions, diff

Source: Internet
Author: User

1. Diff

1) Name

Diff-find differences between two files

Synopsis

Diff [Options] From-file to-file

Description

In the simplest case, diff compares the contents of the two files from-file and to-file.

2) Option

A single letter preceded by-, and the other of which is a long name preceded --. multiple single letter options (unless they take an argument) can be combined into a single command line word:-ac is equivalent to-a-c. long named options can be abbreviated to any unique prefix of their name. brackets ([and]) indicate that an option takes an optional argument.

(1)-A: Set all filesCompositionThis file is used to compare by line.

(2)-B ignore Spaces

-B. Ignore empty rows.

-H uses the test method to accelerate searching for large files

-I case-insensitive

-R: Compare files in the directory

-N treat nonexistent files as empty files

-U uses the uniied format. -U "Number of columns" or "-uniied =" Number of columns "to display different file content in a combined manner.

-Y use the side by side output format.

-- When left-column uses the-y parameter, if one row of the two files has the same content, only the content of the row is displayed in the left column.

-- When suppress-common-lines uses the-y parameter, only the difference is displayed.

-W columns use an output width of columns in side by side format. This parameter is used when the y parameter is used.

-T add a Tab character before each line for alignment

-P if the file to be compared is in C LanguageProgramThe function name of the difference.

-C: display all internal text and mark the differences.

-Q: only whether it is the same

3) Example

(1) diff test Test2

Starting with a smaller sign is saved in the first file, and starting with a greater sign is displayed in the second file. Letters A, D, and C indicate the attaching, deleting, and modifying Operations respectively. Diff can distinguish block and character device files and FIFO (MPS queue files) without comparing them with common files.

(2) diff-I-y-W 80 test test1

Reference

[1]Http://www.flatws.cn/article/program/shell/2011-02-23/14053.html

[2]Http://linux.die.net/man/1/diff

[3] a good explanation of the Parameters

Http://www.phpzixue.cn/detail976.shtml

Http://www.wycode.com/linux/shell/2011/0809/1404.html

[4]Http://www.isstudy.com/linux/387.html

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.