What is the difference between «more» and «less» commands?
From man more : ` more is a filter for paging through text one screenful at a time. This version is especially primitive. Users should realize that less(1) provides more(1) emulation plus extensive enhancements.`
3 Answers 3
more is the oldest, less is an improvement and most is an improvement on that.
- 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 of more and less 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.
Yet another great alternative: bat , available on official repos since Ubuntu Eoan 19.10 or Debian unstable sid.
@JörgWMittag It has to go with Linux (the complete operating system, not the kernel) because Linux has these commands. Otherwise it’s like someone said «I hate Windows because of drive letters.» and you said «I fail to see what drive letters have to do with Windows. Drive letters are from CP/M.» — makes no sense, does it?
@user253751: There are Linux operating systems that don’t use GNU and thus don’t have less . There are Linux operating systems that aren’t Unix-compatible and thus don’t have more . No Linux operating system I ever used had most installed by default. Some even didn’t have it at all. Conversely, all non-Linux Unices have more . There are GNU operating systems that have less but don’t use Linux. There are operating systems that have most but don’t use Linux. For example, I use macOS, which has nothing to do with Linux, and I have all three.
@user253751: I did not know that, and I have never heard anybody use it this way. Anyway, it doesn’t really make a difference, since most is not part of GNU, so the argument that most has nothing to do with Linux still holds even if, for some strange reason, you choose to re-define «Linux» to mean «GNU/Linux». I have always taken «Linux» to mean «Linux», «GNU» to mean «GNU» and «GNU/Linux» to mean «GNU/Linux». I think it would be very confusing to have both «Linux» and «GNU/Linux» mean «GNU/Linux» and have «Linux» not mean «Linux».
The Joke
There is an old joke consisting of three words: “less is more”. (This is the “pun” referred to by guillermo chamorro’s second comment to the question.) Perhaps one reason why people like the joke so much is that the statement can be understood in three different ways, and so there isn’t any clarity about which way is meant. Yet, all three of the ways are accurate, at least on some operating systems. (Point #2 might not apply to Ubuntu, and I do understand that this is an Ubuntu-focused site. However, Ubuntu derives from Debian wish has strong history of ideas being taken from, and shared with, the rest of Unix and Unix-ish systems. So, understanding what other operating systems do isn’t a bad thing.)
- There is a variable named LESS_IS_MORE
- As an indisputable fact of less’s nature (on some operating systems)
- As a simple English statement
- There is a variable named LESS_IS_MORE .
- The less command supports a shell/environment variable named LESS_IS_MORE . The less command acts quite a bit like the older more command by default, but if the less command sees this variable is set to a value of 1 (the number one), then the less command will offer fewer features in an attempt to be increase just how compatible it is with the older pager command that is named more .
- This is not Ubuntu-specific, and is supported by less on all platforms. This is mentioned by less (1) ( less ‘s «man page»), section titled “Compatibility with more ”.
- As an indisputable fact of less’s nature (on some operating systems)
- The less command supports a behavior which many programs utilize in Unix-like environments, which is the behavior of checking which filename it was run as. If the command line which ran the less program started with a filename of more , then what the program named less will do is to act with increased compatibility with the older more command, similar to what it would so if the LESS_IS_MORE command is run.
- Some operating systems have actually relied upon this functionality, and not bothered to include a separate program named more . Well, to be clear, there is an available command named more (which is highly recommended for compatibility with scripts and some quite-common user behavior), but the less and more commands are both “hard links” to the same stream of bits of executable code. So, the executable code which the operating system runs when running the command named less actually is the same executable code which the operating system runs when running the command named more . (This isn’t even just a case of an identical copy of the code being run. Literally, the same bits get loaded by reading from literally the same exact location of the data-storage device, so it is quite literally the same code that gets used.) So, the statement that less is more refers to a literal (factual, non-opinionated, provable) truth, as these are literally the exact same program since both of these programs are literally using the exact same executable code. (However, the program may differ in behavior based on which command was used to run the program.)
- If someone says “ less is more , literally.” then the person is probably trying to clarify that the less command and the more command are sharing the same executable bits. This can be done as a “hard link” (implemented using ln ) most efficiently, but could also be implemented using a “symbolic link” (implemented using ln -s ), or by having a duplicate copy of the executable file’s bits (which can be easily implemented using cp ).
- As a simple English statement
- This is an opinionated statement (which very many people agree with), stating that the less command has a greater number of nice features, and so the less command is a better experience than what is offered by the older, more traditional pager command (which happens to be named more ). Since the experience of using the command named less is a significantly nicer experience, people feel that it is appropriate to describe that nicer experience as being “MORE!”.
Throughout this answer, I did strive to make all references to the command be noticeably marked. However, the best way to experience the joke is verbally, because that adds to some of the ambiguity. Verbally, saying
might all be pronounced in exactly the same way, so if voice tone doesn’t clearly indicate any particular emphasis on any specific words, then simply hearing the three words gives no real indication of precisely which accurate statement(s), if any, was intended to be referenced to a greater extent than the other statement(s).
All humor aside, this may also be used as a bit of a way to measure someone’s familiarity with this command Unix program. Many people don’t read the “man page” for every single command before they use the command (especially when learning how to effectively use some of the most basic commands on the first Unix platform they use), so many people end up learning about the LESS_IS_MORE variable when this joke is fully explained. So, verbally saying this joke can be a way to check how much acknowledgement or confusion the recipient seems to have.
(If the person looks a bit perplexed, that could be an indication that this can be a good time will be taken to help educate the person about the multiple aspects of this statement. Based on the first point or two, they end up knowing a bit more about the behavior of a common command. And if they remember the joke, then they can remember the last point, which helps them to remember about the existence of the less command which many people are happier with, and remember which command typically provides a nicer experience on many platforms.)
DOS compatibility
There is one aspect to the “ more ” command that is worth mentioning, which might make it seem nicer (in the opinions of at least some people) than the “ less ” command.
Very, very many Unix(-ish) systems come with both a command named more and a command named less , built-in, installed as part of the operating systems. (The command named most , which further builds upon the less command, is mentioned by one of the other answers, but is pre-installed on far fewer systems. So, installing the program needs to be done first.) However, the more command may also be pre-installed on a larger number of computers, including computers that are not typically thought of as being designed primarily around Unix compatibility.
In MS-DOS and similar/compatible platforms, including modern Microsoft Windows, the following will work precisely like it does with Unix:
You can also pipe into more . A typical way of demonstrating this is to show a command that reveals the contents of a text file. In Unix, that is often done using cat . MS-DOS does not have a cat command, but instead uses type . (Unix has a separate type command that does something quite different.) So:
(Remember, when I mention DOS, that also applies to modern Microsoft Windows, not to mention other systems like OS/2. So, these DOS references are as relevant to the modern world today as what Microsoft Windows is.)
As a more modern example, the following works on modern Microsoft Windows systems, and also on many Unix systems:
With modern versions, you can also specify one or more filenames on the command line. If you do, the first file will be shown, and then the next file will be shown.
While the less command is available for MS-DOS, Microsoft Windows, and other operating systems, the program is often not pre-bundled. So, the less command is not available unless some effort is made to install the system. If you step foot into a computer lab that you have not been to before, chances are quite good that the command named more might be readily available, while the command named less might typically only be available on Unix platforms. For some people, this may be an advantage to the command named more which is significant enough for them to prefer to get used to running that command.
Misc
I don’t try to provide the entire answer here, because doing so would just be redundant with the other answers. Instead, I decided to just include information that I wasn’t seeing elsewhere. So this answer is designed to be supplemental to some other answers. I hope you enjoyed the information presented here, but definitely check out the other answers. Both of the pre-existing answers (posted before this one) also provided additional information.