'Linux - cmp doesn't show line number on files differing only in extra lines
So I'm comparing two files and trying to output the position (line number and byte number) of the first difference between them.
Using the cmp command I get the necessary output, that works for most files: $ cmp file1 file3
output: file1 file3 differ: byte 7, line 2
However for files that differ only by appended extra lines, it doesn't output the line/byte number $ cmp file1 file2
output: cmp: EOF on file1
Tried using other commands like diff (comm also, but it's no good), but couldn't get the byte number this way $ diff file1 file2 | head -n 1
output: 2a3
Is there any way to eliminate this problem? I'm trying to find a command to get an output similar to the first case that works for an input like the second case.
Considering the following text files:
file1:
line1
line2
file2:
line1
line2
line3
file3:
line1
different
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
