The Cat command in Linux is generally used to concatenate files. However, apart from that, it can even be used for creating files and viewing their contents on the Linux terminal. At times, while running this command in Linux, you might feel like exiting from this command. Therefore, in this guide, we will discuss the different methods of exiting from the Cat command in different scenarios on a Linux Mint 21 system.
Different Scenarios of Exiting from the Cat Command in Linux Mint 21
The two different scenarios in which you might feel like exiting from the Cat command are discussed below:
Scenario # 1: While Creating a File with the Cat Command
You can use the Cat command for creating a new file as follows:
$ cat > newfile.txt
When you will run this command, you will be allowed to enter some text in your newly created text file as shown below:
Once you are done with adding text to your text file, you might want to save it and exit from the Cat command. To do that, you simply need to press the “Ctrl + D” key combination and you will instantly exit from the Cat command as shown in the following image:
Scenario # 2: While Viewing a File with the Cat Command
There are different terminal pager commands available in Linux such as “less”, “more”, “most”, etc. that you can use for viewing the contents of your file page by page. While using the Cat command with any of these terminal pager commands, you might want to exit at any moment. The Cat command along with a terminal pager command is shown below:
$ cat newfile.txt | less
The output of this command is shown in the following image:
However, as soon as you feel like exiting from the Cat command without going all the way to the last page, you can simply press the “q” key. Right after doing this, you will return to the regular terminal as shown in the image below:
This article was meant to convey the methods of exiting from the Cat command on a Linux Mint 21 system in different scenarios. We first introduced you to the basic purpose of this command. After that, we discussed with you the two methods of exiting from this Command in two different situations. Therefore, now you can use any of these methods according to the situation which you are in while using a Linux Mint 21 system.
Please visit this link if you like the Cat command to go page by page.