What is the difference between the two commands below?
more file-name
less file-name
What is the difference between the two commands below?
more file-name
less file-name
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 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.
To clarify these:
LESS_IS_MORE.
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.less on all platforms. This is mentioned by less(1) (less's "man page"), section titled “Compatibility with more”.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.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.)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).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
less is more”less is MORE!”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.)
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:
more < filename.txtYou 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:
cat file.txt | moretype file.txt | more(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:
netstat -na | moreWith 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.
more fileone.txt filetwo.txtWhile 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.
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.
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.
From the less man pages:
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.)
From the more man page:
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.