Windows EOF CTRL-D equivalent




In Linux and MacOS environments, you can terminate standard input by outputting EOF (end of file) using the CTRL-D keyboard shortcut. In Windows, the CTRL-D key combination does not do the same. Lets look at how to accomplish this in Windows Command Prompt or Powershell.

How to send EOF in Windows

In Windows Command Prompt or Powershell, the equivalent of CTRL-D requires a two-step sequence:

CTRL-Z followed by <return>

Try it out with a Python script

Example of a Python script that will read standard input until EOF is reached:

import sys

Then execute the file with:


Type all you want, press <return> as many times as you want. When you are done, press CTRL-Z then <return> and it will finish readining standard input and perform the print operation.


After following this guide, you should be able to emulate the CTRL-D behavior to generate an EOF signal in Windows using CTRL-Z followed by <return>.