cat

file managementLinux/Unix
The cat command is one of the most frequently used commands in Linux/Unix-like operating systems. cat Concatenate and display files

Quick Reference

Command Name:

cat

Category:

file management

Platform:

Linux/Unix

Basic Usage:

cat filename.txt

Common Use Cases

    Syntax

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

    Options

    Option Description
    -n Number all output lines
    -b Number non-empty output lines
    -A Show all non-printable characters
    -s Suppress repeated empty output lines
    -T Display tab characters as ^I
    -v Show non-printing characters using ^ and M- notation

    Examples

    How to Use These Examples

    The examples below show common ways to use the cat command. Try them in your terminal to see the results. You can copy any example by clicking on the code block.

    # Basic Examples
    cat filename.txt
    Display the contents of a file.
    cat file1.txt file2.txt
    Concatenate and display multiple files.
    cat -n filename.txt
    Display file contents with line numbers.
    # Advanced Examples Advanced
    cat > newfile.txt
    Create a new file and write content to it.
    cat file1.txt file2.txt > combined.txt
    Combine multiple files into a new file.
    cat file3.txt >> combined.txt
    Append content to an existing file.
    cat -A filename.txt
    Display non-printing characters.

    Try It Yourself

    Practice makes perfect! The best way to learn is by trying these examples on your own system with real files.

    Understanding Syntax

    Pay attention to the syntax coloring: commands, options, and file paths are highlighted differently.

    Notes

    These are sample notes for the cat command.

    Related Commands

    These commands are frequently used alongside cat or serve similar purposes:

    Use Cases

    Learn By Doing

    The best way to learn Linux commands is by practicing. Try out these examples in your terminal to build muscle memory and understand how the cat command works in different scenarios.

    $ cat
    View All Commands