What is the difference between "more" and "less" commands?
What is the difference between the two commands below?
more file-name
less file-name
Solution 1:
more
is the oldest, less
is an improvement and most
is an improvement on that.
Short comparison:
-
more
: forward navigation and limited backward navigation. -
less
: both forward and backward navigation and also has search options. You can go to the beginning and the end of a file instantly. Plus you can switch to an editor (like open the file in vi or vim). It is noticeably quicker than editor for when the file is large. -
most
: has all the features ofmore
andless
but you can also open multiple files, close 1 file at a time when you have multiple files open, allows locking and scrolling of the open windows and allows for splitting of open windows.
All 3 use the h
to let you view the keybindings for the command.
Solution 2:
less
lets you navigate upwards as well as downwards.
That's the most important difference, but there are many others. less
provides numerous features beyond those in more
. You can press H in less
and it will show you its abbreviated help, explaining how to use its various interactive features.
Most common are Spacebar or Page Down to go down one screenful of text and B and Page Up to go back up one screenful of text. All four arrow keys work (though the up and down arrows are the ones most often useful).
less
also differs from more
in some ways that pertain to performance, resource usage, and accommodating unusual terminals. As man less
says:
Less is a program similar to more (1), but it has many more features. Less does not have to read the entire input file before starting, so with large input files it starts up faster than text editors like vi (1). Less uses termcap (or terminfo on some systems), so it can run on a variety of terminals. There is even limited support for hardcopy terminals. (On a hardcopy terminal, lines which should be printed at the top of the screen are prefixed with a caret.)
Commands are based on both more and vi. Commands may be preceded by a decimal number, called N in the descriptions below. The number is used by some commands, as indicated.
I've been comparing less
to a traditional implementation of more
. In Ubuntu, more
is such an implementation. However, if you invoke less
but as the name more
--as would happen if you made a symlink or hardlink to less
called more
and ran that--then it behaves differently, resembling more
aesthetically but allowing you to move both upward and downward in documents.