List the Contents of a File in Linux Mint 20.3 Using the Cat Command

The cat command in Linux can also be used for viewing the contents of a file very effectively.

Here at LinuxAPT, we shall look into the different ways in which you can use the cat command for displaying the contents of a file in Linux Mint 20.3.


Different ways of Using the Cat Command for listing the Contents of a File in Linux Mint 20.3

We will be using two different files for demonstration in these examples i.e. sample.txt and test.txt. You can learn to Use CAT Command to Combine Text Files in Ubuntu 20.04 : https://linuxapt.com/blog/281-use-cat-command-to-combine-text-files-in-ubuntu-20-04


1. Listing the Contents of a Single File with the Cat Command

You can list the contents of a single file with the help of the cat command:

$ cat sample.txt

Here, "sample.txt" is the name of the text file whose contents we want to list down.


2. Using Multiple Cat Commands at Once

At times, you might want to run multiple cat commands at once for listing the contents of more than one file at a time. Below is the command format:

$ cat sample.txt; cat test.txt

Here, "sample.txt" and "test.txt" are the two text files whose contents we want to list down. In the same manner, you can also list down the contents of more than two files by using multiple cat commands with the file names while separating them with the help of semi-colons.


3. Listing the Contents of Multiple Files with a Single Cat Command

A better way of listing down the contents of multiple files at once is by using a single cat command. This process will not only be more efficient but will also be computationally less expensive. You can do this by running the cat command:

$ cat sample.txt test.txt

Here, we have used the same text files that we had used in our second example. However, this time, instead of using multiple cat commands while separating them with semi-colons, we have used a single cat command followed by the names of all the files whose contents are to be displayed. The names of these files have been separated simply by using spaces.


[Need help in fixing Linux Mint system issues ? We can help you. ]

This article covers the different ways of using the cat command for listing the contents of a file in Linux Mint 20.3. In fact, The "cat" command is very frequently used for viewing, creating, and appending files in Linux.

Related Posts