CON – Windows CMD Command
CON (short for Console) is an input device, not a command.
Syntax
Copy from the console to a new file:
COPY CON filename.txt
Type from the console to a new file:
TYPE CON > Newfile.txt
Type from the console to overwrite a file:
TYPE CON >> Newfile.txt
After entering any of these commands, type in the text required, note there is no obvious prompt for this, then end the file by typing CTRL-Z, this will insert an EOF marker: ASCII 0x1a (SUB).
When using COPY the CTRL-Z can be placed anywhere, but when using TYPE it is important that the CTRL-Z is only entered at the beginning of a new line, otherwise, it will just be saved into the file and you will have two EOF markers in the same file.
Most basic text editors will stop reading after the first EOF marker.
Some commands e.g. CLS, do not work as expected when redirected to CON and will output extra control characters.
To do this in Powershell use the following function:
function copycon {
[system.console]::in.readtoend()
}
con is a reserved filename.
More advanced use of the console device is to redirect the console CON into FIND and then redirect the output from FIND into a file, this will make FIND discard any lines which do not contain the desired text. This can be useful for condensing large log files to return only the lines of interest.
Example:
C:\> FIND /i "Jones" <con > logfile.txt
asdf
asdf
zz Jones 2
asdf
^Z
C:\> TYPE logfile.txt
zz Jones 2

I genuinely enjoy looking through on this site, it has got great articles. “The longing to produce great inspirations didn’t produce anything but more longing.” by Sophie Kerr.