5 ms·
I don't understand the new line thing at the end. I haven't used a utility or app in -decades- that cared about whether you have a blank final line.
by stjohnswarts 5y ago
I don't understand the new line thing at the end. I haven't used a utility or app in -decades- that cared about whether you have a blank final line.
- usefulcat 5y agoI think it used to be a requirement (technically) for C and C++, though probably not much any more in practice.
- xigoi 5y ago`cat`, for instance, definitely cares.
- ziml77 5y agoI just ran into an issue with that recently. The Pandas library for Python doesn't consume the last line of a CSV unless it's followed by a new line. I would say I couldn't believe that it actually made inject that newline if it wasn't in the input, but Pandas has enough other oddities that it was pretty easy to believe.
- jeffreygoesto 5y agoThe GreenHills C++ compiler does. It's a niche product, admitted.
- draxil 5y agobreaks some crontabs.
- shric 5y agoThere's a few reasons I can think of (some superficial, some significant): - Github and git will highlight a missing newline in a diff by default. - POSIX defines a line as having a newline at the end, so if you don't have a terminating new line you may have one fewer lines than you think you have [1] - If you ever want to append to a text file/source file programmatically with something like echo "something at the end" >> yourfile.txt then you'll be grateful you had the habit of ending everything with a newline. - If you use a shell that doesn't automatically add one when you do cat filename you'll end up with your prompt sitting awkwardly at the end of the file. vim, iirc, defaults to automatically adding a newline to any file without you explicitly asking for it, unless you do set noeol and set binary or, in versions newer than 7.4, set nofixendofline [1] https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap03.html#tag_03_206 https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1...
- thayne 5y ago> vim, iirc, defaults to automatically adding a newline to any file without you explicitly asking for it, unless you do set noeol and set binary or, in versions newer than 7.4, set nofixendofline which, IMO, is the right way to do it. In kakoune however, it isn't just the default, there is no way to turn it off.
- Someone 5y agoDo you ever do wc? It cares: > echo hello > hello > echo -n hello > hellon > wc hello hellon 1 1 6 hello 0 1 5 hellon 1 2 11 total
- 3836293648 5y agoLiterally cat
- gnubison 5y agoHave you used cat recently? [Edit: scrolled down, looks like several other people already beat me to it. Whoops.]