title: How to send EOF from command prompt *without newline*?
body: <p>Sure, to send EOF from command prompt, <kbd>Enter</kbd> followed by <kbd>Ctrl-Z</kbd> does the trick.</p>
  
  <pre><code>C:\&gt; type con &gt; file.txt
  line1
  line2
  ^Z
  </code></pre>
  
  <p>This works, and <code>file.txt</code> contains <code>line1\r\nline2\r\n</code>. But how can you do the same without the last newline, so that <code>file.txt</code> contains <code>line1\r\nline2</code>?</p>
  
  <p>In Linux, the solution is to hit <kbd>Ctrl-D</kbd> twice<sup>1</sup>. But what is the equivalent on Windows? Command prompt will happily print <code>^Z</code>s at the end of a line without doing sending EOF. (And if you press <kbd>Enter</kbd>, then any <code>^Z</code>s you typed get written to the file as literal escape characters!)</p>
  
  <p>If there is no way to do this on Windows, then why?</p>
  
  <hr>
  
  <p><sup>1</sup> <a href="https://askubuntu.com/questions/118548/how-do-i-end-standard-input-without-a-newline-character">https://askubuntu.com/questions/118548/how-do-i-end-standard-input-without-a-newline-character</a></p>