Linux and Unix cat command

Quick links

About cat
Syntax
Examples
Related commands
Linux and Unix main page

About cat

Allows you to look, modify or combine a file.

Syntax

cat filename [-n] [-b] [-u] [-s] [-v]

filename The name of the file or files that you wish to look at or perform tasks on.
-n Precede each line output with its line number.
-b Number the lines, as -n, but omit the line numbers from blank lines.
-u The output is not buffered. (The default is buffered output.)
-s cat is silent about non-existent files.
-v Non-printing characters (with the exception of tabs, new-lines and form-feeds) are printed visibly. ASCII control characters (octal 000 - 037) are printed as ^n, where n is the corresponding ASCII character in the range octal 100 - 137 (@, A, B, C, . . ., X, Y, Z, [, \, ], ^, and _); the DEL character (octal 0177) is printed ^?. Other non-printable characters are printed as M-x, where x is the ASCII character specified by the low order seven bits.
-e A $ character will be printed at the end of each line (prior to the new-line).
-t Tabs will be printed as ^I's and formfeeds to be printed as ^L's.

*If the -v is used -e and -t will be ignored.

Examples

cat file1.txt file2.txt > file3.txt

Reads file1.txt and file2.txt and combines those files to make file3.txt.

Related commands

ed
pico
tac
tee
touch