
The Unix and the Echo (2001) - charlysl
https://everything2.com/title/The+UNIX+and+the+Echo
======
hunter2_
If you have a file consisting of some text, the file might or might not end
with a \n

If you have a file consisting of some lines of text, the file will end with a
\n because a line of text (unlike text generally) is typically defined by
matching ^[^\n]*\n

Therefore, `echo` with no arguments returns a line of text which contains
nothing.

~~~
charlysl
I think you are right, it is a matter of convenience, to type less, as the
story hints, but not only for writing to files, also for displaying messages
on the console.

According to the book quoted in the link:

 _Since a command should by default execute its most commonly used function,
... echo appends the final newline automatically._

It may seem insignificant, but this story highlights, in nerd humour, some of
the design philosophy behind Unix.

Classic Kernighan (as the book's co-author).

------
LeoPanthera
"echo -n" will omit the trailing newline, on both Linux and BSD. echo -n with
no other arguments therefore outputs literally nothing.

(Except for the "echo" builtin in /bin/sh, which does not recognise -n.)

~~~
teddyh
Debian GNU/Linux guarantees that the echo builtin, even in /bin/sh, supports
the -n option:

[https://www.debian.org/doc/debian-policy/ch-
files.html#scrip...](https://www.debian.org/doc/debian-policy/ch-
files.html#scripts)

------
saagarjha
> f u cn rd ths u mst uz unix

I thought this was cursing at me at first!

By the way, if you actually care about your newlines use printf.

------
jeffrallen
Everything2 rocks. I used to be a somewhat prolific noder.

------
TedDoesntTalk
I'd say they overthought the behavior of echo... just a little bit.

