Read file from Windows CMD (Command Line)


If you want to read a file using the Windows CMD command and print it on the console, you can make use of the type command,

Type: Displays the contents of a text file or files.

Syntax: TYPE [drive:][path] filename

Example:
C:\>type d:\countries.txt
China
USA
France
Poland
Sweden
Japan
Australia
C:\>

If the file is too huge then type command will keep on buffering the text on the console, in such a case you can make use of more command,

C:\>more d:\countries.txt
China
USA
France
Poland
Sweden
Japan
Australia
India
Nepal
Bhutan
Sri Lanka
Germany
Canada
-- More (78%) --
More command Windows CMD
More command Windows CMD
C:\>help more
Displays output one screen at a time.

MORE [/E [/C] [/P] [/S] [/Tn] [+n]] < [drive:][path]filename
command-name | MORE [/E [/C] [/P] [/S] [/Tn] [+n]]
MORE /E [/C] [/P] [/S] [/Tn] [+n] [files]

    [drive:][path]filename  Specifies a file to display one
                            the screen at a time.

    command-name            Specifies a command whose output
                            will be displayed.

    /E      Enable extended features
    /C      Clear screen before displaying page
    /P      Expand FormFeed characters
    /S      Squeeze multiple blank lines into a single line
    /Tn     Expand tabs to n spaces (default 8)

            Switches can be present in the MORE environment
            variable.

    +n      Start displaying the first file at line n

    files   List of files to be displayed. Files in the list
            are separated by blanks.

    If extended features are enabled, the following commands
    are accepted at the -- More -- prompt:

    P n     Display next n lines
    S n     Skip next n lines
    F       Display next file
    Q       Quit
    =       Show line number
    ?       Show help line
    <space> Display next page
    <ret>   Display next line


















Copyright © Code2care 2024 | Privacy Policy | About Us | Contact Us | Sitemap