cat

Print a file in the terminal, number its lines, or join several files into one output.

>_ Try it: a simulated Linux, right here
Loading the terminal…

Examples

  • cat todo.txt
  • cat -n ideas.txt
  • cat todo.txt ideas.txt
  • cat /etc/os-release
  • cat todo.txt | grep docker

How it works

cat FILE prints the whole file in the terminal. It is the quickest way to read a config file or a short note.

Give it several files and it prints them one after the other (that is where the name comes from: concatenate). For long files, head and tail show just the start or the end.

Syntax

cat [OPTION]... FILE...

Options

OptionWhat it does
-nnumber every line

Good to know

  • cat is not for folders: cat notes says "Is a directory". Use ls notes to look inside a folder.
  • Piping cat into grep works, but grep docker todo.txt does the same with one command.