Skip to content

cat command

Print files, join them together, or create small files.

On this page

Syntax

cat [options] [file…]

Provided by the coreutils package. Run man cat for the full manual.

Common options

OptionWhat it does
-nNumber all lines
-bNumber non-empty lines
-sSqueeze repeated blank lines
-AShow tabs, line ends and other invisible characters
-EShow $ at the end of each line

Examples

  1. Print a file

    cat /etc/os-release
  2. Print with line numbers

    cat -n script.sh
  3. Join files into one

    cat part1.txt part2.txt > full.txt
  4. Append a file to another

    cat extra.txt >> main.txt
  5. Create a file from the keyboard (Ctrl+D to finish)

    cat > notes.txt
  6. Show hidden characters

    cat -A file.txt

Tips

  • For long files use less; for the start or end use head or tail.

cat guides

← All Linux commands · Suggest a fix

Back to top