TYPE – Windows CMD Command

Display the contents of one or more text files.

If more than one file is specified the filenames are included in the output.
If a wildcard is used the filenames are displayed even if only one file matches. The file names are printed to the error stream and so can be hidden by redirecting to NUL  TYPE * 2>nul

Errorlevels

If the file(s) were successfully displayed %ERRORLEVEL% = 0
If the file was not found or bad parameters given %ERRORLEVEL% = 1

TYPE is an internal command.

Examples:

This will require typing a CTRL-Z to indicate the end of file.

When using redirection to SORT a file the TYPE command is used implicitly
For example:

The technique above (based on a script by Carlos M.) first creates a file with a Byte Order Mark (BOM) and then appends the content of the original file. CHCP is used to ensure the session is running with the Windows1252 code page so that the characters 0xFF and 0xFE (ÿþ) are interpreted correctly.

It is also possible to convert files from Unicode to ASCII with TYPE or MORE see the redirection syntax page for details.


You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *