MORE or LESS: Displaying Contents Page-Wise

By | August 29, 2016

Using the command line is a time-honoured tradition in Linux (at least for those that like to get their hands dirty with commands). One of the common acts carried out when using the CLI is that of displaying and manipulating texts, and Linux is so much rich with commands to achieve this. The cat command is a very good example.

The cat command is used to display the content of a file on screen. However, if the file being displayed is large, then the entire content will scroll up the screen. To view the file one screen-full at a time, you can use the more or less commands;

THE more COMMAND

The more command is to display data one screen-full at time while viewing a file using the more command, once you have scrolled down you cannot move up

More <option> <filename_of_any_textfile>

The above command will display a pagewise (text divided based on the size of the screen viewed one screen-full at a time) listing of the contents of the file.

THE less COMMAND

The less command is similar to the more command except that you can scroll upwards also while viewing the contents of a file. The less command is also a little faster than the more command.

less <options> <filename_of_textfile>

They can prove very valuable because both commands (more and less) can also be used to read the outputs of commands that can span more than one page. Examples include the following;

env | more or env | less

dmesg | more or env | less

tree | more or tree | less

After using the less or more; to move up and down the screen, you can use the arrow keys. You can also specify a number to move down the screen by that number of lines. To quit the display, you have to type q.

Happy Linux’NG!


NEVER MISS AN UPDATE



I agree to have my personal information transfered to MailChimp ( more information )

Join over 10,000 visitors to receive Open Source tips, trick, news, tutorials, programming and more.

We hate spam. Your email address will not be sold or shared with anyone else.

ALEXANDER OMOROKUNWA
MUST READ  Voters Registration the FOSS Way

Tell us what you think

This site uses Akismet to reduce spam. Learn how your comment data is processed.