N Days to learn the diff of a Linux command

Source: Internet
Author: User

Use

Compare file differences by row, or you can compare directories

Usage
diff [OPTION]... FILES
Common options

-I.--ignore-case
Ignore case

--ignore-file-name-case
Ignore file name capitalization

--no-ignore-file-name-case
File names are case sensitive

-E--ignore-tab-expansion
Ignore tab characters

-B--ignore-space-change
Ignore spaces

-W--ignore-all-space
Ignore All spaces

-B--ignore-blank-lines
Ignore blank lines

-I RE--ignore-matching-lines=re
Filter rows that match

--strip-trailing-cr
Remove end of line carriage return character

-A--text
All file contents as text

-c-c NUM--context[=num]
(Output NUM (default 3) lines of copied context.)

-u-u NUM--unified[=num]
(Output NUM (default 3) lines of unified context.)

--label Label
Use label instead of file name

-P--show-c-function
Show the file where the difference line is located

-F RE--show-function-line=re
(Show the most recent line matching RE.)

-Q--brief
Whether the direct output results are different

-E--ed
(Output an ED script.)

--normal
(Output a normal diff.)

-N--rcs
(Output an RCS format diff.)

-Y--side-by-side
Output 2 files at the same time, control display

-W NUM--width=num
(Output at the most NUM (default) print columns.)

--left-column
Left output full content, right only output difference

--suppress-common-lines
Output only differential rows

-D NAME--ifdef=name
(Output merged file to show ' #ifdef NAME ' diffs.)

--gtype-group-format=gfmt
(Similar, but format GTYPE input groups with GFMT.)
(GTYPE is LTYPE or ' changed '.)

--line-format=lfmt
(Similar, but format all input lines with LFMT.)

--ltype-line-format=lfmt
(Similar, but format LTYPE input lines with lfmt.)
(LTYPE is ' old ', ' new ', or ' unchanged ')

-L--paginate
Pagination Display

-T--expand-tabs
tab character changed to space when output

-T--initial-tab
(Make tabs line up by prepending a tab.)

-R--recursive
(recursively compare any subdirectories found.)

-N--new-file
(Treat absent files as empty.)

--unidirectional-new-file
(Treat absent first files as empty.)

-S--report-identical-files
(report when both files are the same.)

-X PAT--exclude=pat
(Exclude files that match PAT.)

-X FILE--exclude-from=file
(Exclude files, match any pattern in FILE.)

-S FILE--starting-file=file
(Start with FILE when comparing directories.)

--from-file=file1
(Compare FILE1 to all operands. FILE1 can be a directory.)

--to-file=file2
(Compare all operands to FILE2.) FILE2 can be a directory.)

--horizon-lines=num
(Keep NUM lines of the common prefix and suffix.)

-D--minimal
(Try hard to find a smaller set of changes.)

--speed-large-files
(Assume large files and many scattered small changes.)

-V--version
Output Program Version information

--help
Display Help information

Practice

1 Comparison of 2 files

# 显示所有diff -y dir1/friend.php friend.php# 只显示差异diff -y --suppress-common-lines dir1/friend.php friend.php# 只显示左边完整内容,右边只显示差异内容diff -y --left-column dir1/friend.php friend.php
Wipe reference

"1" Man diff

N Days to learn the diff of a Linux 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.