Skip to content

The cat command

Print the contents of files. Prints each file, one after the other (cat is short for concatenate). With no file, it reads what is piped into it. To see only the start or the end of a long file, use head or tail.

Usage

cat [OPTION]... [FILE]...

Options

-n, --numbernumber every line

Examples

  • cat notes.txtShow a file
  • cat -n notes.txtShow it with line numbers
  • cat part1.txt part2.txt > whole.txtJoin two files into a third

Learn it step by step

learner@sandbox: ~bash (practice)
Note: Try cat here: your home directory has sample files. Press Try beside an example, or type your own.

A practice shell in your browser that behaves like bash on Linux for these commands. Nothing you type leaves the page.