Linux diff TR Tee command

Source: Internet
Author: User
Tags diff

Diffcompare two files or directories in different places

And they all take the first file as the object of action:

The first file is much more than the second one, and it needs to be deleted, and less to be added. Is the same as the second file that will eventually become the first file.

example Two file 1.txt and 2.txt:

1D0: The first line of the first file is deleted in the same way as thesecond file line 0 (which is the beginning of the line)

< Hi,

2A2: The second line of the first file is incremented just as the second line of the second file

> Hi,

4,5C4: First file IV, the five elements changed to be the same as the fourth line of the second file

< I am Fine,

< Thank you.

---

> I am Fine.

' < ' represents the deleted row, while the ' > ' represents the added row.

Y or --side-by-side displays the similarities and differences of the files in a parallel manner.

-W< Width > --WIDTH< width > using -y parameter, specify the width of the column.

" | "indicates before and after 2 The contents of the file are different

" < "indicates fewer files later than the previous file. 1 Line Content

" > "indicates that there are more files behind than the previous file. 1 Line Content


- C Show all the text and mark the difference.

"+" indicates that the next file has more than 1 lines of content

"-" indicates that the subsequent file is 1 less than the previous line

"! " indicates that the contents of the front and back 2 files are different

"---" indicates the document before the change, "+ + +" means the document after the change


- Q or --brief Show only if there is no difference, no detailed information is displayed.

-u,-u or --unified= displays the different contents of the file in a merged manner.

the front" -1,5"divided into three parts: The minus sign represents the first file,"1"represents the first1Line,"5"represents a continuous5line. Together, it means that the following is the first file from the1row start of continuous5line. The same,"+1,4"represents a change after becoming the second file from the first1row start of continuous4line.

How to Understand:

If two files contain the same text but differ in case, diff command will still report it differently by default

-I ignores case

But then there will be no output generated, because when the two files are the same as the default behavior, if you want to see the prompt say the same thing:

-S option reports the same two files


Use -B to ignore spaces

Compare two files differently and produce patches


In addition to files, thediff command can compare two directories



Vimdiff

There is only one row in a file, the color is relative

Two files exist, but contain differences in the behavior of one color, causing the difference to also add a font background

Ctrl + W + W Toggle left and right or up and down switch

DP copies the line on the left cursor to the right line

Do copy the right side of the line to the left cursor

Https://jingyan.baidu.com/article/ae97a646da05debbfd461d33.html


Tr

Many of the most basic functions of SED are easy to implement.

You can substitute one character for another, or you can completely remove some characters. can also be used to remove duplicate characters


Replace characters by character and replace without modifying source files


lowercase replaced with uppercase


Remove Characters of Z


Remove line breaks

PS: Invisible characters have to be represented by an escape character, this is all unified



Replace the newline character with:


except for a-Z and line break, delete

except for the 1-2 number, delete


Delete duplicate


Tee

we usually like ls >a.txt, when we can't see the output

ls | Tee/tmp/ls.txt

-A Append input


The standard error is also entered into the file.


Although repeated printing, but only once appended to the file



Linux diff TR Tee 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.