4 ms·
Pedantically, if it doesn't end with a newline, it's considered a binary file and not a text file. Binary files don't have lines. In practice, most utilities e
by coryrc 3y ago
Pedantically, if it doesn't end with a newline, it's considered a binary file and not a text file. Binary files don't have lines.
In practice, most utilities expecting text files will still operate on it.
- PaulDavisThe1st 3y agoNo file has lines. "Lines" are a convention established by (or not) software reading a data stream.
- coryrc 3y agoAckshully
- wtetzner 3y agoThat's a weird way to look at it. Binary files might not have "lines", but there's no reason they couldn't include a byte with value 10 (the ASCII value for \n). Software reading that file wouldn't know the difference, right? Also, why couldn't you have a text file without any lines?
- coryrc 3y agoAll I'm addressing is GP's comment: It's a file with zero complete lines. But it has 1 line, that's incomplete, right? Because the Unix definition of text file requires the file to end with a newline. "Lines" only exist in the context of text files. If there's no terminating newline, it's (pedantically) not a text file and so has no lines. Now, in practice, if you open() that file in text mode, it doesn't TMK return an error if the terminating newline isn't present, but it's undefined behaviour. And if you do have a terminating newline, then you have at least one line :).