type - Display a Text File

Maintained on

Being able to quickly check the contents of a text file is very useful when working with the command prompt or batch files.

This article introduces how to display the contents of a text file using the type command.

Basics of the type command

The type command displays the contents of a text file on the screen.

You can check the contents directly at the command prompt without opening the file.

Basic usage at the command prompt

- □ ×
Command Prompt Icon
Command Prompt
Microsoft Windows [Version xx.x.xxxxx.xxx]
(c) 2026 Ribbit App Development All rights reserved.
 
C:\users\user>type sample.txt
This is a sample text file.
The contents are displayed with the type command.
C:\users\user>

When you run this command, the contents of the sample.txt file are displayed on the screen.

Basic usage in a batch file

@echo off
setlocal

type sample.txt

endlocal
exit

When you run this batch file, the contents of the sample.txt file are displayed on the screen.

type command syntax

The basic syntax of the type command is as follows.

type [drive:][path]filename

Parameter description

ParameterDescription
[drive:][path]filenameSpecifies the location and name of the file to display
/?Displays help at the command prompt
チェック

If the file name contains spaces, it must be enclosed in double quotation marks (").

type command examples

Displaying a single file

As the most basic usage, display a single text file.

- □ ×
Command Prompt Icon
Command Prompt
Microsoft Windows [Version xx.x.xxxxx.xxx]
(c) 2026 Ribbit App Development All rights reserved.
 
C:\users\user>type readme.txt
Project name: Sample Application
Version: 1.0.0
Created: October 3, 2025
C:\users\user>
おすすめ書籍※ 広告を含む場合があります
中小企業経営者のためのRPA入門 RPA導入を成功させる方法

中小企業経営者のためのRPA入門 RPA導入を成功させる方法

60分でわかる! AIエージェント 超入門

60分でわかる! AIエージェント 超入門

コマンドラインの黒い画面が怖いんです。

コマンドラインの黒い画面が怖いんです。

知識・才能ゼロでもらく~に月10万円稼ぐ! よくわかるAI副業超入門

知識・才能ゼロでもらく~に月10万円稼ぐ! よくわかるAI副業超入門

Displaying multiple files in sequence

By specifying multiple file names separated by spaces, you can display multiple files in sequence.

- □ ×
Command Prompt Icon
Command Prompt
Microsoft Windows [Version xx.x.xxxxx.xxx]
(c) 2026 Ribbit App Development All rights reserved.
 
C:\users\user>type file1.txt file2.txt
file1.txt
Contents of file 1
file2.txt
Contents of file 2
C:\users\user>

When you specify multiple files, the file name is displayed before each file.

You can also display multiple files together by using a wildcard, such as type *.txt.

When the file name contains spaces

If the file name contains spaces, enclose it in double quotation marks.

- □ ×
Command Prompt Icon
Command Prompt
Microsoft Windows [Version xx.x.xxxxx.xxx]
(c) 2026 Ribbit App Development All rights reserved.
 
C:\users\user>type "My Document.txt"
Contents of a file whose name contains spaces
C:\users\user>

Combining with pipes

For long files, you can combine it with the more command to display one page at a time.

- □ ×
Command Prompt Icon
Command Prompt
Microsoft Windows [Version xx.x.xxxxx.xxx]
(c) 2026 Ribbit App Development All rights reserved.
 
C:\users\user>type long_file.txt | more

When you run this command, the contents of the file are displayed one page at a time, and you can move to the next page by pressing the Space key or the Enter key.

Searching the contents of a file

By combining it with the find command, you can display only the lines in a file that contain a specific string.

- □ ×
Command Prompt Icon
Command Prompt
Microsoft Windows [Version xx.x.xxxxx.xxx]
(c) 2026 Ribbit App Development All rights reserved.
 
C:\users\user>type config.txt | find "port"
port=8080
C:\users\user>

Practical examples in batch files

Check the contents of a log file

@echo off
setlocal

echo ========================================
echo Displaying the contents of the log file
echo ========================================
echo.

type error.log

endlocal
exit

Display multiple configuration files at once

@echo off
setlocal

echo ========================================
echo Contents of the configuration files
echo ========================================
echo.

echo [Database settings]
type db_config.txt
echo.

echo [Server settings]
type server_config.txt
echo.

echo [Application settings]
type app_config.txt

endlocal
exit

Concatenate multiple files into one file

By redirecting the output of type, you can combine multiple text files into one.

@echo off
setlocal

type part1.txt part2.txt > merged.txt
echo Files have been concatenated

endlocal
exit

However, because the file name lines are also output, use copy /b part1.txt+part2.txt merged.txt if you want to concatenate only the contents. For copying files, the basic approach is to use the copy command rather than type.

For redirection, see the following page.

Notes

チェック

When you display a binary file or a file created by a program with the type command, strange characters may appear on the screen. This is caused by the control codes contained in binary files. In general, we recommend using the type command only to display text files.

チェック

When you display a UTF-8 file, Japanese text may appear garbled. In that case, switch the code page to UTF-8 with chcp 65001 and then run the command. For details on character encoding, see the following page.

In preparation
The linked page is currently under construction. Please wait a moment.

Using it in PowerShell

In PowerShell, type works as an alias for the Get-Content cmdlet.

The syntax differs, but you can display the contents of a file in the same way.

type sample.txt
# or
Get-Content sample.txt

Summary

The type command is a handy tool for quickly checking the contents of a text file.

Main features:

  • Simple and easy-to-use syntax
  • Multiple files can be displayed at the same time
  • Can be combined with other commands using pipes
  • Well suited to automation in batch files

Because you can check the contents without opening the file, it greatly improves work efficiency.

It is especially useful for everyday tasks such as checking log files and configuration files.

#Command Prompt #Batch Files #Command Line #Commands