57

When I do more filename and less filename, it would seem that the resulting terminals are quite similar. I can navigate and search through my files identically (j, Space, /pattern, etc.).

I find it hard to believe that less is more and vice versa. Are there any differences between the two?

Zaid
  • 10,642

8 Answers8

62

The difference is mostly historical at this point, I believe some systems even have more and less hardlinked to the same binary.

Originally, more pretty much only allowed you to move forward in a file, but was pretty decent for buffering output.

less was written as an improved more that allowed you to scroll around the displayed text

The first line of my man less pretty much sums it up:

Less is a program similar to more, but which allows backward 
movement in the file as well as forward movement. 
user455
  • 1,260
  • @jkerian : Text-searching and buffering aside, could you show a practical example of where these two differ in terms of command implementation? – Zaid Aug 17 '10 at 21:26
  • @Zaid: I could if I could get hold of one of the systems I was using fifteen years ago. It really doesn't matter any more. – David Thornley Aug 17 '10 at 21:31
  • 17
    I don't see that it's historical I've never seen a 'more' that allowed you to move in both directions. you can only move forward in more. the historical point would be that more was written before less, meaning 'see more than 1 page' and less's command name is more of a joke on less is more and more is less, basically saying less could do more things. – xenoterracide Aug 17 '10 at 21:55
  • @jkerian which systems have a more that is the same binary as less? (other than busybox based systems) – xenoterracide Aug 17 '10 at 22:05
  • FreeBSD has them hardlinked, for one. – user455 Aug 17 '10 at 22:19
  • AIX defaults to more instead of less. I alias them to each other since I keep typing less, when on AIX. – geoffc Aug 18 '10 at 01:35
  • In Mac OS X they are also hard-linked. – Sergio Acosta Aug 18 '10 at 02:33
  • On Ubuntu 10.04, /bin/less and /bin/more have different file sizes. And more --help shows completely different output then less --help They are not the same. – Stefan Lasiewski Aug 18 '10 at 04:33
  • 1
    I have a Solaris 10 system here where more acts like the old fashioned more--- you can't move back a page. And it's the default PAGER. Drives me mad... – Stefan Lasiewski Aug 18 '10 at 04:34
  • 1
    So in other words it's the FreeBSD (maybe all BSD?) based systems... since OS X is based FreeBSD... @Stefan Solaris's default shell without tab completion (enabled?) drove me mad. – xenoterracide Aug 18 '10 at 05:57
  • 9
    More or less the correct answer. – invert Aug 18 '10 at 09:25
  • @xenoterracide: I can move backwards with more on my Mandriva system by pressing b (and no, it's not the same binary as less). – Troubadour Aug 20 '10 at 13:57
  • On OSX, more calls less, but apparently with different arguments (like quitting when you hit EOF). – Steve Bennett May 14 '12 at 14:07
  • Sometimes less is more! – iProgram Aug 30 '15 at 19:34
30

less is a lot more than more, for instance you have a lot more functionality:

g: go top of the file
G: go bottom of the file
/: search forward
?: search backward
N: show line number
: goto line
F: similar to tail -f, stop with ctrl+c
S: split lines

And I don't remember more ;-)

Kent Pawar
  • 1,276
  • 4
  • 16
  • 37
Bauna
  • 551
10

In addition to the extra features already mentioned in less, it also has a v command which opens the current file in vi at the same position. When you exit vi, you will be back in less with the (possibly updated) file shown.

Archemar
  • 31,554
dr-jan
  • 554
4

Ubuntu still has distinct less/more bins. At least mine does, or the more command is sending different arguments to less.

In any case, to see the difference, find a file that has more rows than you can see at one time in your terminal. Type cat, then the file name. It will just dump the whole file. Type more, then the file name. If on ubuntu, or at least my version (9.10), you'll see the first screen, then --More--(27%), which means there's more to the file, and you've seen 27% so far. Press space to see the next page. less allows moving line by line, back and forth, plus searching and a whole bunch of other stuff.

Basically, use less. You'll probably never need more for anything. I've used less on huge files and it seems OK. I don't think it does crazy things like load the whole thing into memory (cough Notepad). Showing line numbers could take a while, though, with huge files.

kāgii
  • 374
  • 2
  • 3
  • 1
    The reason you see this behavior is that one of the parameters a program gets on startup is the name it was called by. If you take the "less" binary and copy or link it to "more", then running it through "more" changes its behavior because it knows it should be running in compatibility mode.

    There's actually a fair bit of this going on in a modern Unixy system. On some systems, for instance, mv, cp and rm are all the same binary, just changing behavior depending on how it was called. An extreme example of this is the Busybox project, popular in embedded Linuxes.

    – Warren Young Aug 17 '10 at 21:54
  • The file sizes for /bin/more and /bin/less are different, and they each show a single hardlink (The column contains a 1). – Stefan Lasiewski Aug 18 '10 at 04:36
4

There are a couple of things that I do all the time in less, that doesn't work in more (at least the versions on the systems I use. One is using G to go to the end of the file, and g to go to the beginning. This is useful for log files, when you are looking for recent entries at the end of the file. The other is search, where less highlights the match, while more just brings you to the section of the file where the match occurs, but doesn't indicate where it is.

KeithB
  • 3,209
  • 20
  • 13
3

Less has a lot more functionality.

You can use v to jump into the current $EDITOR. You can convert to tail -f mode with f as well as all the other tips others offered.

geoffc
  • 668
  • 4
  • 13
  • 18
3

At least on systems I've used:

  • more exits automatically when you reach the end of the file
  • less requires you to exit explicitly.
2

Also less can view zipped/compressed file, more can't do that.