What are the differences between "less" and "more"?
As I understand it, less
is more
+ the ability to scroll up. Is it correct? Is there any reason to use more
instead of less
? Are there any significant differences I'm missing out?
less is a full-screen application that gives you a searchable, scrollable window and clears the screen after you exit, less can also be backgrounded and restored like other full screen terminal applications. less also has a command to open the currently viewed file in your default editor.
more just prints the text as is, stopping for page breaks, and does not clear the screen, it can be backgrounded but it doesn't clear the screen. more also only reads in the file as it displays where less may read the file into memory first. each handles line wrapping differently which gives different results when selecting and pasting text.
both tools fulfill the same function but they do it in different ways, so you can pick whichever one you want for the situation at hand.
From my less(1)
:
DESCRIPTION
Less is a program similar to more (1), but which allows backward movement in the file as well as forward movement. Also, 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).
[...]
COMPATIBILITY WITH MORE
If the environment variable LESS_IS_MORE is set to 1, or if the program is invoked via a file link named "more", less behaves (mostly) in conformance with the POSIX "more" command specification.
If you check, you may find that on your system, less
is in fact precisely more
, with compatibility as described above:
$ shasum $(which less) $(which more)
268084f9ca3528888f01010b1f4f49100177f553 /usr/bin/less
268084f9ca3528888f01010b1f4f49100177f553 /usr/bin/more