Use less command to view long text documents

by Daniel Pham
Published: Updated:
This entry is part 3 of 6 in the series Linux commands: Part 3 - Exploring the system

In the Linux system, there are very long text files, such as system log files. To be able to view long text files easily, you can use the less command.

What is the less command?

The less command is a program designed to replace a previously existing command on Unix that is more. The word less comes from the phrase “less is more“, which is the motto of modern architects.

Like the more command, the less command lets you view the content of a text file as pages, which is crucial when you want to see the content of a very long text file. Other than the more command can only view the page forward, the less command can view the page backward.

Use the less command to view long text

Less command is very simple to use, you just need to type the command and followed by the file name (or absolute path to the file).

"less

The table below lists the most common keyboard commands used by less:

KeyAction
Page Up or bScroll back one page
Page Down or spaceScroll forward one page
Up ArrowScroll up one line
Down ArrowScroll down one line
GMove to the end of the text file
1G or gMove to the beginning of the text file
/charactersSearch forward to the next occurrence of characters
nSearch for the next occurrence of the previous search
hDisplay help screen
qQuit less

Conclusion

For long text files on linux, you will often have to use the less command and hopefully through this article, those who are new to Linux will use it more easily.

(This is an article from my old blog that has been inactive for a long time, I don’t want to throw it away so I will keep it and hope it helps someone).

Linux commands: Part 3 - Exploring the system

Use “file” command to determine the type of file Create links with ln command
0 0 votes
Article Rating

You may also like

Subscribe
Notify of
guest
0 Comments
Newest
Oldest Most Voted

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More

0
Would love your thoughts, please comment.x
()
x

Adblock Detected

Please support us by disabling your AdBlocker extension from your browsers for our website.