3 Incomplete Lines

When an input file ends in a non-newline character, its last line is called an incomplete line because its last character is not a newline. All other lines are called full lines and end in a newline character. Incomplete lines do not match full lines unless differences in white space are ignored (see Suppressing Differences in Blank and Tab Spacing).

An incomplete line is normally distinguished on output from a full line by a following line that starts with ‘\’. However, the RCS format (see RCS Scripts) outputs the incomplete line as-is, without any trailing newline or following line. The side by side format normally represents incomplete lines as-is, but in some cases uses a ‘\’ or ‘/’ gutter marker. See Showing Differences Side by Side. The if-then-else line format preserves a line’s incompleteness with ‘%L’, and discards the newline with ‘%l’. See Line Formats. Finally, with the ed and forward ed output formats (see diff Output Formats) diff cannot represent an incomplete line, so it pretends there was a newline and reports an error.

For example, suppose F and G are one-byte files that contain just ‘f’ and ‘g’, respectively. Then ‘diff F G’ outputs

< f
\ No newline at end of file
> g
\ No newline at end of file

(The exact message may differ in non-English locales.) ‘diff -n F G’ outputs the following without a trailing newline:

d1 1
a1 1

diff -e F G’ reports two errors and outputs the following: