'cat' is not recognized as an internal or external command

avatar
Borislav Hadzhiev

Last updated: Apr 4, 2024
3 min

banner

# 'cat' is not recognized as an internal or external command

The error "'cat' is not recognized as an internal or external command, operable program or batch file" occurs when we use the cat command on Windows, in a CMD shell.

To solve the error, use the type command to display the contents of a file.

cat is not recognized as internal or external command

The type command is the Windows equivalent of the Unix/Linux cat command.

cmd
# ๐Ÿ‘‡๏ธ Display the contents of a file named my_file.txt type my_file.txt # ๐Ÿ‘‡๏ธ Display the contents of a lengthy file named my_file.txt, one screen at a time type my_file.txt | more

running type command windows

Make sure to replace the my_file.txt placeholder with the name of the file you want to read.

The type command is used to display the contents of a text file.

You can pipe the output of the command to the more command to display the contents of a lengthy file, one screen at a time.

cmd
# ๐Ÿ‘‡๏ธ Display the contents of a lengthy file named my_file.txt, one screen at a time type my_file.txt | more

Note that you can use the cat command in PowerShell.

To open PowerShell:

  1. Click on the Search bar and type "PowerShell".

start powershell

  1. Click on the "Windows PowerShell" application.

Run the cat command directly in PowerShell to read the contents of a file.

PowerShell
cat my_file.txt

windows powershell cat command

If you need to open PowerShell in a specific folder:

  1. Open the folder in a window.
  2. Press Shift and right-click in Explorer.

windows open powershell window here

  1. Click on "Open PowerShell window here".
  2. Run the cat command.
PowerShell
cat my_file.txt
Alternatively, you can run the cat command in Git Bash by installing git on your Windows machine.

If you already have git installed, you can search for Git Bash and use the cat command, otherwise, you have to install git first.

# Running the cat command in Git Bash

To download git and be able to use Git Bash:

  1. Open the git downloads page and download the installer for Windows.
  2. Start the installer.
  3. You will be prompted to select a destination location. You can leave the default option and click Next.

git select destination location

  1. You will be prompted to select components on the next screen. Leave the default options and click Next.

git select components

  1. Click Next on the screen that prompts you to "Select Start Menu Folder".

  2. On the next screen, you can choose the default editor for Git, e.g. Notepad, Notepad++ or any other editor you prefer.

choose git default editor

  1. On the "Adjust the name of the initial branch in new repositories screen", click Next.

adjust name of initial branch

  1. On the "Adjust your PATH environment" screen, make sure you have the default option of "Git from the command line and also from 3rd-party software" option selected and click "Next".

adjust your path environment

  1. For all the remaining screens, leave the default option selected and click Next.
  2. Lastly, click on the Install button to install git.

Once you have git installed, click on the Search field, type "Git Bash" and start the application.

search for git bash

Now you can use the cat command directly in Git Bash.

GitBash
cat my_file.txt

using cat command in git bash

If you need to open Git Bash in a specific folder:

  1. Open the folder in a new window.
  2. Right-click in Explorer.

adjust your path environment

  1. Click "Git Bash Here".

Now you can use the cat command to display the contents of a text file.

GitBash
cat my_file.txt
I wrote a book in which I share everything I know about how to become a better, more efficient programmer.
book cover
You can use the search field on my Home Page to filter through all of my articles.

Copyright ยฉ 2024 Borislav Hadzhiev