Windows- Cat Equivalent Command in PowerShell and cmd

What is cat command and how to use cat in Windows or windows cat equivalent?

cat command ( short for concatenate) is one of the powerful command to create single or multiple files, view contents of the file, concatenate multiple files, copy the content to other files, and print output to terminal or file. Cat command is mostly used in Linux and other operating systems. The cat command is called cat as it is used to concatenate files. For example, to display the contents of a file, use cat filename.txt, to view the large file, use cat filename.txt | more

If you use cat command in windows cmd (command prompt/command line), it will throw an exception as ‘cat’ is not recognized as an internal or external command, operable program, or batch file.

cat command in windows cmd (command prompt)
cat command in windows cmd (command prompt)

In Microsoft Windows operating system, if you use the help cat command in windows PowerShell terminal, it gives below output

PS C:\> help cat
NAME
    Get-Content

SYNTAX
    Get-Content [-Path] <string[]> [-ReadCount <long>] [-TotalCount <long>]
    [-Tail <int>] [-Filter <string>] [-Include
    <string[]>] [-Exclude <string[]>] [-Force] [-Credential <pscredential>] 
    [-UseTransaction] [-Delimiter <string>]
    [-Wait] [-Raw] [-Encoding {Unknown | String | Unicode | Byte | 
    BigEndianUnicode | UTF8 | UTF7 | UTF32 | Ascii |
    Default | Oem | BigEndianUTF32}] [-Stream <string>]  [<CommonParameters>]

    Get-Content -LiteralPath <string[]> [-ReadCount <long>] [-TotalCount <long>]
    [-Tail <int>] [-Filter <string>]
    [-Include <string[]>] [-Exclude <string[]>] [-Force] [-Credential <pscredential>]
     [-UseTransaction] [-Delimiter
    <string>] [-Wait] [-Raw] [-Encoding {Unknown | String | Unicode | Byte | 
    BigEndianUnicode | UTF8 | UTF7 | UTF32 |
    Ascii | Default | Oem | BigEndianUTF32}] [-Stream <string>]  [<CommonParameters>]


ALIASES
    gc
    cat
    type


REMARKS
    Get-Help cannot find the Help files for this cmdlet on this computer. 
    It is displaying only partial help.
        -- To download and install Help files for the module that includes 
     this cmdlet, use Update-Help.
        -- To view the Help topic for this cmdlet online, type: 
     "Get-Help Get-Content -Online" or
           go to https://go.microsoft.com/fwlink/?LinkID=113310.

Help cat command in windows PowerShell output.

Cool Tip: cat in Windows alias are type, gc, and Get-Content

In the above PowerShell terminal, the help cat command gives output as Get-Content and other aliases used for cat alternative in windows. You can use windows cat equivalent type, gc and Get-Content cmdlets.

The type command is a Windows cat equivalent that works across a command-line prompt (cmd) and a Window’s PowerShell. type command used in Windows to view contents of the given file without modifying it.

In this post, I will quickly show you how to display the contents of a file to the screen using cat equivalent in windows.

Windows Cat equivalent in cmd & PowerShell : type

type command syntax in windows

Syntax

type [<Drive>:][<Path>]<FileName>

Parameters

[<Drive>:][<Path>] : location and name of the file to use for view contents.

<FileName> : Single file name or separate multiple file names with spaces on cmd

Windows Cat equivalent – type command Examples

To get help on type command

type /?

The above command in cmd gets help on windows cat equivalent type command and displays contents of a text file or files. Help command gives output as

TYPE [drive:][path]filename

To view single file content using type command

C:\>type file.txt

It will display a view of the file.txt file as given in the below image

powershell cat type view file content
window type command – view file content

Cool Tip: How to get permissions on folders and subfolders!

Windows Cat equivalent – view multiple file content using type

Sometimes, it is necessary to view content of the file which are locked by another program and also copy the content to another file. type command in windows provides an easy way of doing it.

C:\> type file1.txt ,file2.txt > resultfile.txt
C:\> type resultfile.txt

In the above command, we have used two files separated by , in PowerShell. If you are using a command prompt use separator as space. Two files concatenated output will be store in resultfile.txt.

The second command, type resultfile.txt display contents on the screen. windows cat equivalent type command doesn’t lock the file it is viewing on the screen.

Cool Tip: Use set-aduser to modify active directory user attributes!

To view large size file content

C:\>type logs.txt | more

Sometimes, we may need to view the contents of a lengthy file like a log file. In order to view lengthy content, use more filter to view content on screen one line at a time.

type Command FAQ

What is cat equivalent command in windows?

The type command is a Windows cat equivalent that works on command-line prompt and a Windows PowerShell.

You can also use GC-Content alias of cat command in windows.

How to use cat command in windows?

Use type command in windows to view the contents of the text file or files. If you need more help, use type /?
type command syntax is TYPE [drive:][path]filename

what is the windows equivalent of the unix command cat?

cat command in unix is used to concatenate files and print content. windows type command is used to display content of text file. You can also use Get-Content cmdlet to display content

‘cat’ is not recognized as an internal or external command

cat command not used in windows. If you use cat in windows command prompt (cmd), it will display message as `cat` is not recognized as an internal or external command, operable command or batch script.

use type command in command line or PowerShell. However, if you use Get-Help cat on PowerShell, it gives output as Get-Content which is an alias of type command.

Best type command windows example

type command best feature is to view the content of the file without locking the file and event copy the contents of the file which are locked by another program to a different file

How to concatenate two text files in PowerShell?


Let’s consider two files file1.txt and file2.txt, to concatenate two files using PowerShell, use the below command

type file1.txt file2.txt > resultfile.txt

above command concatenate file1.txt and file2.txt into resultfile.txt file.

Does cat command works in Windows?

cat command use to create single or multiple files, concatenate files, view the contents of the file. cat command in windows doesn’t work. If you type cat in windows cmd, it will throw an error as `cat` is not recognized as an internal or external command. However, you can use cat alias command Get-Content or type to perform the same operation as cat command.

Cool Tip: Know more about how to get aduser using userprincipalname!

Conclusion:

Windows operating system doesn’t have cat command in window. using cat command in cmd line, it will throw an exception as “‘cat’ is not recognized as an internal or external command, operable program or batch file” however, using cat command in PowerShell displays its alias command as Get-Content and type.

type command is a built-in alias of Get-Content cmdlet which also displays the contents but with different syntax.

In the above post, I explained how to use cat equivalent command in Windows using built-in command type to display file contents, view lengthy files, and view multiple files contents.

You can find more topics about PowerShell Active Directory commands and PowerShell basics on ShellGeek home page.

Leave a Comment