Follow Techotopia on Twitter

On-line Guides
All Guides
eBook Store
iOS / Android
Linux for Beginners
Office Productivity
Linux Installation
Linux Security
Linux Utilities
Linux Virtualization
Linux Kernel
System/Network Admin
Scripting Languages
Development Tools
Web Development
GUI Toolkits/Desktop
Mail Systems
Eclipse Documentation

How To Guides
General System Admin
Linux Security
Linux Filesystems
Web Servers
Graphics & Desktop
PC Hardware
Problem Solutions
Privacy Policy




Node:Incomplete Lines, Next:, Previous:Output Formats, Up:Top

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 White Space).

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) 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 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 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:


  Published under the terms of the GNU General Public License Design by Interspire