How to Make the Cat Command Go Page by Page?
The most important purpose of the Cat command in Linux is to display the content of a file or files on the terminal. However, at times, you have to deal with large files whose contents cannot fit into the terminal window at once. In that case, you should prefer to make the Cat command go page by page. Therefore, in this guide, we will discuss the methods of displaying the contents of a file page-wise while using the Cat command on a Linux Mint 21 system.
Two Ways of Making the Cat Command go Page by Page in Linux Mint 21:
Below we will be talking about the two different methods of making the Cat command go page by page:
Method # 1: Using the “More” Command:
If the file whose contents you are trying to display is too large, then you can use the “more” command with the Cat command for making it display the contents page by page. This command is as follows:
$ cat SampleFile.txt | more
Running this command will only display the first page of your file on the terminal as shown in the image below:
In the image shown above, you can notice the “–More–” label at the end of the page. It is an indication that there are still more pages of this file to be viewed. To view those pages one by one, you need to press the Space Bar key. Once you will reach the last page of your file, you will get the control of the terminal back as shown in the following image:
Method # 2: Using the “Less” Command:
You can also pair up the “less” command with the Cat command in Linux to make the Cat command go page by page as shown below:
$ cat SampleFile.txt | less
Again, this command will only display the content of your specified file that can fit inside one pager view as shown in the image that follows:
You will be able to see a “:” at the end of the page indicating that there are still more pages to be viewed. You can view these pages by pressing the “f” key or the Space Bar key. Once you will reach the last page, the “(END)” label will appear on the terminal indicating that you have reached the end of the file as shown in the image below:
In this guide, we shared with you the two methods of making the Cat command go page by page on a Linux Mint 21 system. Now, you can conveniently view the contents of large files in your Linux Mint 21 terminal.