3 ms·
Unix's first job in life was as a documentation processing system. It was made to be very good at dealing with text. All of the tools which process text expect
by bityard 2y ago
Unix's first job in life was as a documentation processing system. It was made to be very good at dealing with text. All of the tools which process text expect every line to end in a newline. The last line is not exempt from this. All classic Unix text editors will automatically append a trailing newline to any text file you create with them. Some modern tools may be _tolerant_ of omitted trailing newlines, but you shouldn't rely on that. A text file should always have a newline as its last character. Otherwise, it's not _really_ a text file.
POSIX defines it more succinctly than I do: A text file contains one or more "lines" and every "line" is terminated by a "newline."
https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap03.html#tag_03_2 https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1...
https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap03.html#tag_03_403 https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1...