Use the UNIX CAT command in Linux to list out the contents of a file. It can also be used to combine the data of two such files.

Don’t forget to check out our site for more free how-to videos!
– our feed
– join us on facebook
– our group in Google+

In this tutorial we will show you how to use the unix cat command.
This command is used for displaying the contents of the file. The unix commands for cat can also be used for combining copies of the files and creating new ones.

To understand how to work with the cat command, follow the tutorial steps given below.

Step 1 — List the directory contents

Let’s look at an example over here. First, let’s list the contents of the directory here.

Step 2 — Display contents of the text

Let’s display the contents of the text file over here. For that, simply write “cat text.txt” And over here, you can see all the data being displayed on the screen.

Step 3 — Display contents of two files together

Now we will see how we can combine two files with the cat command. Over here, notice that there are two text files. So, over here, we will type
“cat textfile textfile1”.
You will see that the contents of both the files will be displayed together.

Step 4 — Combine two text files

Now let’s use the unix cat command to create a new text file from the terminal.
For that type cat file1
You will be required to fill the content in the newly created file. So let’s write a single line over here and then press the CTRL + D key. This is used for saving the file.

Step 5 — Check if the files have been combined

Let’s check whether the changes had been saved or not. For that, simply write the cat command followed by the name of the file.
And over here, you can see that the changes had been made, and the file contains the content that we had entered earlier.
So that’s it, follow the steps above to learn how unix commands for cat can be used to list the contents of an existing file or even combining two such files.


Xem thêm bài viết khác:



May 3, 2020

way too bland ..


Sasindu Dharmawardhana

May 3, 2020

cat file1 file2 > file3
will this copy the content of the file1 and file2 into file3 ?


Ximon Shadow

May 3, 2020

"ctr + d" to save


Marco C.

May 3, 2020

short, sweet, to the point


Leave a Reply