
The less
command lets you page through a text file, displaying a screenful of text each time. It seems like one of the simplest Linux commands at first glance, but there’s a lot more to less than meets the eye.
The History of less
Everything in Linux–and Unix—has a history, no pun intended. The less
program is based on the more
program, which was initially released in 1978 in version 3.0 of the Berkeley Software Distribution Unix (3.0BSD). more
allowed you to progressively page through a text file, displaying a screenful of text at a time.
Necessity being the mother of invention, it was the inability of early versions of more
to scroll backward through a file that prompted Mark Nudelman to develop less
and to overcome that specific problem. That work started in 1983, and the first version was released outside of the company he worked for in 1985. As of October 2019, he is still the maintainer of less
.
I wonder if there is a Linux user who hasn’t used less
? Even if they haven’t used it to page through a chosen text file, chances are they’ve used the man
command. And man
calls less
behind the scenes to display the man
pages.
This is a command with a lot of tricks up its sleeve.
Why less Is Better Than more
less
has been added to steadily over the years. It has a staggering amount of command-line options and in-application command keystrokes. Do a quick comparison of the man page for less and the man page for more
, and you’ll start to see how less
absolutely towers over more
.
more
has overcome its initial failing of not being able to page backward through text, but only for files. It cannot page backward through piped input. You can do that with less
.
With its flexibility in navigating files, viewing multiple files, searching for text, dropping and returning to bookmarks, and dealing with piped input, less
wins hands down. Use less
instead of the more
.
Reading a File With less
To load a file into less
, provide the name of the file on the command line:
less Dr-Jekyll-and-Mr-Hyde-001.txt
0 Response to How to Use the less Command on Linux
Post a Comment