Creating a file without a newline

I recently was at a tech event where there was some discussion about newlines in templates. I pointed out that relying on implicit newlines in template files can lead to problems. The short discussion ended with a statement that files always end in a newline, and people moved on.

So, here's an example how you can bring a file without newlines into existence, even without an editor.

$ echo -ne "foo" > bar
$ wc -l bar
0 bar
$ cat bar 


Start a new thread

Cancel reply