I am using diff with the -y
and --suppress-common-lines
options and the output is almost perfect except I'd like to see the line numbers of the changes.
Example:
file1:
line a
line b
line c
file2:
line a
line B
line c
line d
command and output:
$ diff -y --suppress-common-lines file1 file2
line b | line B
> line d
Is this combination of options possible with diff or do I need another tool?
They are line-numbers for the old/new files to help the patch (or similar) program decode the unified-diff. the number before the comma is the line number for the beginning of the chunk. The + and - signs refer to adding and deleting lines, respectively.
The Linux diff command is used to compare two files line by line and display the difference between them. This command-line utility lists changes you need to apply to make the files identical. Read on to learn more about the diff command and its options with easy-to-follow examples.
Output generated by diff is a collection of information of each line within different group types. Further, it gives three options – namely, –line-format, –LTYPE-line-format, and –GTYPE-group-format – for fine control of the output format.
Unfortunately the -y
option uses the formatting style internally (as does --LFMT-line-format
), you cannot cumulate formatting commands with -y
.
You cannot obtain from formatting parameters what -y
does, so you cannot workaround directly with diff
(I checked diff 3.2 source code).
You need to use another tool.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With