Type

Index

The TYPE command is used to display the contents of an ASCII text file on screen.

Syntax:

TYPE filename

Notes:

  1. To display text files one screen at a time, pipe the output from a TYPE command to MORE.

  2. TYPE does not support wildcard file specifications. If this is required, use COPY (see below).

  3. TYPE is primarily used:
    • to display formatted text on the screen during the running of a batch file. This could be a menu leading up to a CHOICE command, or a warning/advice before proceeding with some operation. Although slightly slower to display than using ECHO, it is much easier to edit a text file than a series of ECHO statements.
    • to feed the contents of a text file into a command using redirection.

  4. To modify a text file, search for a particular word, or move from one page to another and back, use Notepad in Windows95 or EDIT in Dos.

  5. TYPE is a special case of the COPY command - indeed:
    TYPE filename
    is exactly equivalent (as far as I can see) to:
    COPY filename CON > NUL

Examples:

  1. To display the contents of HOLIDAY.MAR:
    TYPE holiday.mar

  2. If the file is too long to fit on a single screen:
    TYPE holiday.mar | MORE

  3. To pipe the contents of GO.TXT to a DEL command requiring confirmation before deleting all files in a directory.
    TYPE go.text | DEL *.*
    If the first two characters of GO.TXT contain a "Y" or "y" followed by an [Enter], the files will be deleted. Anything else and the operation will be skipped.

File Details:

Internal


This page last revised:
March 10, 2002.