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.

Raw
$ echo -ne "foo" > bar
$ wc -l bar
0 bar
$ cat bar 
foo$
Published on July 15, 2019 by Nicolas . You can follow the discussion with the comment feed for this post. Feeling generous? Donate!

0 comments

Start a new thread

Cancel reply
Markdown. Syntax highlighting with <code lang="php"><?php echo "Hello, world!"; ?></code> etc.