How to Print a File in the Terminal with cat
To check what's inside a small text file, such as a settings file, a note or a generated password file, you don't need an editor. cat prints the file in the terminal. Give it two files and it prints one after the other, which is where its name comes from: concatenate. PowerShell's version is Get-Content.
Syntax
In zsh and bash:
cat <file> [<file> ...]
| Part | What it means |
|---|---|
<file> | The file to print. Give several to print them in order |
The macOS manual page for cat says: "The cat utility reads files sequentially, writing them to the standard output." Standard output is your terminal.
In PowerShell:
Get-Content <file>[, <file> ...]
Microsoft's documentation says "The Get-Content cmdlet gets the content of the item at the location specified by the path, such as the text in a file". The same page lists its short names: gc and type on every platform, and also cat on Windows.
The Example
Two small files hold a to-do list: note.txt with two lines and more.txt with one. You print the first, then both.
Step 1: Print One File, Then Two
- macOS / Linux
- Windows (PowerShell)
cat note.txt
Buy milk
Call the bank
cat note.txt more.txt
Buy milk
Call the bank
Pay rent
Get-Content note.txt
Buy milk
Call the bank
Get-Content note.txt, more.txt
Buy milk
Call the bank
Pay rent

The second command printed note.txt and then more.txt, with nothing in between. Neither file changed: cat only reads.
Common Mistakes
| Mistake | What happens | Do this instead |
|---|---|---|
| A wrong name or folder | cat: missing.txt: No such file or directory. In PowerShell: Cannot find path '...' because it does not exist. | Check the name with ls |
Giving cat a folder | cat: reports: Is a directory | List a folder with ls |
| Printing a huge file | It scrolls past faster than you can read | Use less to page through it, or head for the first lines |
Troubleshooting
| Symptom | Likely cause | Fix |
|---|---|---|
No such file or directory | The file isn't in the current folder | Run pwd and ls, or give the full path |
FAQ
Can cat create or change a file?
Not on its own. It only reads. Redirection can write its output to a file, as in cat note.txt more.txt > all.txt, which writes the combined text to all.txt.
Is cat safe to use on a secrets file?
It prints the secret to your screen, where others or a screen recording can see it. Print secrets only when you need them and nobody is watching.
Conclusion
cat note.txt printed the file, and cat note.txt more.txt printed both in order. In PowerShell, Get-Content does the same. Use them to look into small text files without opening an editor.
Additional Resources
- Get-Content — PowerShell's command and its options.
man catin your terminal — the manual page on macOS and Linux.
