What is the cat command in Linux?

The cat command is one of the Linux shell commands that the operating system kernel provides. It reads data from files and displays it on the console. It comes from the word 'concatenate,' as we can use this command to display the contents of different files together.

Let's suppose we have to read data from multiple files and merge them into one file. How can we do this?

We do this primarily with the help of the cat command, in which we read data from multiple files. The content in each file would be concatenated with the already read content of the previous file. We can then send all the concatenated data to the new file using pipes.

Syntax

Below we can see the syntax for the cat command:

Error: Code Block Widget Crashed, Please Contact Support

In the command, we see two placeholders:

  • Files: Here, we mention the file path whose content we want to display or concatenate. If we have multiple files, we separate them with a space.

  • Options: This represents the various options we can use to modify the behavior of the cat command. We can see the various options we can use with the command in the table below.

Example

Now that we have reviewed the syntax, let's look at an example to see how the command works. For the purpose of this example, we will use two text files, file1.txt and file2.txt.

Below, we can see the content of both text files.

Error: Code Block Widget Crashed, Please Contact Support
Error: Code Block Widget Crashed, Please Contact Support

In this example, we will concatenate the content in file1.txt and file2.txt. When we click on the terminal, the following command runs to display the concatenated content of both text files.

Error: Code Block Widget Crashed, Please Contact Support
Loading...

Challenge: In the terminal above, try to execute the cat command with the options shown in the table above and observe how the command behaves.

Exercise

Now let's try to solve the exercise below by matching the option to their correct description.

Free Resources

Copyright ©2025 Educative, Inc. All rights reserved