Account
Categories

cat command


Definition:

When you use this command, it shows the content of a file directly in the terminal.

It can also create a new file.

It can join the content of two or more files together into a single file.


Syntax:

cat [option] filename

Example 1:

Command:

cat file.txt

Output:

It shows the content of file.txt on the terminal screen.


Example 2:

Command:

cat > newfile.txt

Output:

It creates a new empty file named newfile.txt.

(You can type text inside it, and then save with Ctrl+D.)


Example 3:

Command:

cat file1.txt file2.txt > combined.txt

Output:

It merges the content of file1.txt and file2.txt into a new file named combined.txt.