3 ms·
Maybe I didn't understand the question, but a file containing zero lines can be stored on all operating systems. It would be a file of size zero bytes and would
by AnonHP 6y ago
Maybe I didn't understand the question, but a file containing zero lines can be stored on all operating systems. It would be a file of size zero bytes and would show up in directories as such. A "> filename" command (or even a "touch" command with a new filename) run on the shell is an easy way to create such a file. A simple file containing one empty line would contain just the newline character (depending on the OS, this may be LF or CR-LF or CR) and would be one or two bytes in size. On disk, both these files would occupy the minimum allocated block size by the OS for files.
- bloak 6y agoYes, I think you didn't understand. The question was "why". If newline characters (hypothetically) separated lines rather than terminated them, like how commas separate fields in some situations rather than terminate them, then, in that hypothetical situation, you would not be able to distinguish zero lines from one empty line. This may not be the historical reason for non-empty files ending with a newline, but it's a motivation for that rule. In most of the cases where commas separate things either those things are not allowed to be empty or there has to be at least one thing, so there's no problem. But you have to watch out for cases in which you don't have those conditions because then you get the ambiguity.