🐧 Linux cat Command

Concatenate and display files to standard output with line numbering and formatting options.

Syntax

$ cat [options] [file_name(s)]

Common Command Options

Option Description
-nNumber all output lines starting with line 1
-bNumber non-empty output lines only
-sSqueeze multiple adjacent blank lines into a single blank line
-EDisplay a $ symbol at the end of each line
-TDisplay TAB characters as ^I
-vUse ^ and M- notation, except for LFD and TAB
-AEquivalent to -vET (show non-printing characters, tabs, and line ends)

Practical Examples

View File Contents
cat myfile.txt
Prints the complete content of myfile.txt to the terminal screen.
Display with Line Numbers
cat -n script.sh
Numbers each line from top to bottom, making debugging and code reviews easy.
Combine Multiple Files
cat header.html body.html footer.html > fullpage.html
Merges three separate HTML files into a single output file named fullpage.html.
Append Content to Existing File
cat extra_logs.txt >> main_log.txt
Appends the content of extra_logs.txt to the end of main_log.txt without overwriting existing data.
Create a New File Interactively
cat > quick_note.txt
Allows you to type directly into the terminal. Press Ctrl+D when finished to save.