File Viewing & Editing

cat

Concatenate and display file contents to standard output.

Synopsis

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

Examples

Display file contents
cat file.txt
Concatenate two files into one
cat file1.txt file2.txt > merged.txt
Display with line numbers
cat -n script.sh
Create file with heredoc
cat << 'EOF' > config.yml
key: value
EOF

Common options

FlagDescription
-nNumber all output lines
-bNumber non-blank lines only
-sSqueeze repeated blank lines
-AShow all non-printing characters
-EDisplay $ at end of each line

About cat

The `cat` command concatenate and display file contents to standard output. Text viewing and editing commands are fundamental tools in any Linux user's toolkit.

Linux treats almost everything as a file, so the ability to quickly inspect, filter, transform, and edit file contents from the command line is critical. These commands are regularly combined with pipes and redirects to build powerful data-processing pipelines.

The command accepts 5 commonly used flags shown above, though the full set of options is available in the man page (`man cat`). The 4 examples on this page cover typical real-world usage patterns that you can copy and adapt for your own workflows.

Related commands

More File Viewing & Editing Commands

Other commands in the File Viewing & Editing category

Related tools