Device File - MS-DOS

MS-DOS

A device file is a reserved keyword used in MS-DOS and MS-DOS–based systems to allow access to certain ports and devices.

MS-DOS uses device files for access to printers and ports. Most versions of Windows also contain this support, which can cause confusion when trying to make files and folders of certain names, as they cannot have these names. A common misconception is that these are bugs which Microsoft has failed to fix.

Device keyword Use as input Use as output
CON Receives typed data until ^Z (Ctrl-Z) is pressed. Prints data to the console.
PRN N/A Prints text to the printer, usually redirected to LPT1.
AUX Reads data from an auxiliary device, usually a serial port. Sends data to an auxiliary device, usually a serial port.
NUL Returns null or no data. Discards received data.
CLOCK$ Returns system real-time clock. (Note that "CLOCK$" no longer appears to exist under Windows 7) N/A
LPT1 (also 2–9) Reads data from the selected parallel port Sends data to the selected parallel port
COM1 (also 2–9) Reads data from the selected serial port Sends data to the selected serial port

Using shell redirection and pipes, data can be sent to or received from a device. For example, typing type c:\data.txt > PRN will send the file c:\data.txt to the printer, although this may not work on all systems or printers.

Read more about this topic:  Device File