DEV Community

Zitouni Abdeldjallil
Zitouni Abdeldjallil

Posted on

3 Basic Cat Command Examples in Linux

The cat (short for “concatenate“) command is one of the most frequently used commands in Linux/Unix-like operating systems. cat command allows us to create single or multiple files, view content of a file, concatenate files and redirect output in terminal or files.

In this article, we are going to find out the handy use of cat commands with their examples in Linux.

General Syntax of Cat Command

$ cat [OPTION] [FILE]...

1. Display Contents of File

cat /etc/passwd


2. View Contents of Multiple Files in terminal

In below example, it will display the contents of the test and test1 file in the terminal.

cat test test1

Hello everybody
Hi world,

3. Create a File with Cat Command

We will create a file called test2 file with the below command.

cat >test2

Thanks for reading ! Happy coding !

Discussion (0)