What do the lines in the diff command mean?

What do the lines in the diff command mean?

Line numbers corresponding to the second file. Like in our case, 0a1 which means after lines 0 (at the very beginning of file) you have to add Tamil Nadu to match the second file line number 1. It then tells us what those lines are in each file preceeded by the symbol:

How can I make two diff files identical?

Unlike its fellow members, cmp and comm, it tells us which lines in one file have is to be changed to make the two files identical. The important thing to remember is that diff uses certain special symbols and instructions that are required to make two files identical.

What do the dashes mean in Linux diff?

After the lines from the first file, there are three dashes (” — “), then a line range, then four dashes (” —- “). This indicates the line range in the second file that will sync up with our changes in the first file. If there is more than one section that needs to change, diff will show these sections one after the other.

What does 3C3 mean in the diff command?

Next line contains 2,3c3 which means from line 2 to line 3 in the first file needs to be changed to match line number 3 in the second file. It then tells us those lines with the above symbols. The three dashes (“—“) merely separate the lines of file 1 and file 2.

What are the line numbers in diff output?

Each consists of a line number or comma-separated range of lines in the first file, a single character indicating the kind of change to make, and a line number or comma-separated range of lines in the second file. All line numbers are the original line numbers in each file. The types of change commands are:

How is the output of diff-u formatted?

The output of diff -u command is formatted a bit differently (so called “unified diff” format). Here diff shows us a single piece of the text, instead of two separate texts.

How to view diff command output in Linux?

Linux system offers two different ways to view the diff command output i.e. context mode and unified mode. -c (context) : To view differences in context mode, use the -c option.