Isn't less just more?

26,265

Solution 1

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. 

Solution 2

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 ;-)

Solution 3

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.

Solution 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.

Solution 5

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.

Share:
26,265
Zaid
Author by

Zaid

Updated on September 17, 2022

Comments

  • Zaid
    Zaid almost 2 years

    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?

    • Admin
      Admin over 13 years
      less is more than more, more or less, more is less than less. ;-)
    • Admin
      Admin almost 11 years
      @AlanHaggaiAlavi - That's quite a tongue twister you have there:D
    • Admin
      Admin over 4 years
      This depends on what Unix is being used. On some, less and more are the same executable, while on others they are different.
  • Zaid
    Zaid almost 14 years
    @jkerian : Text-searching and buffering aside, could you show a practical example of where these two differ in terms of command implementation?
  • David Thornley
    David Thornley almost 14 years
    @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.
  • Warren Young
    Warren Young almost 14 years
    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.
  • xenoterracide
    xenoterracide almost 14 years
    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
    xenoterracide almost 14 years
    @jkerian which systems have a more that is the same binary as less? (other than busybox based systems)
  • user455
    user455 almost 14 years
    FreeBSD has them hardlinked, for one.
  • geoffc
    geoffc almost 14 years
    AIX defaults to more instead of less. I alias them to each other since I keep typing less, when on AIX.
  • Sergio Acosta
    Sergio Acosta almost 14 years
    In Mac OS X they are also hard-linked.
  • Mark Norgren
    Mark Norgren almost 14 years
    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.
  • Mark Norgren
    Mark Norgren almost 14 years
    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...
  • Mark Norgren
    Mark Norgren almost 14 years
    The file sizes for /bin/more and /bin/less are different, and they each show a single hardlink (The column contains a 1).
  • xenoterracide
    xenoterracide almost 14 years
    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.
  • invert
    invert almost 14 years
    More or less the correct answer.
  • Troubadour
    Troubadour almost 14 years
    When more is interactive it too can start vi by pressing v.
  • Troubadour
    Troubadour almost 14 years
    @xenoterracide: I can move backwards with more on my Mandriva system by pressing b (and no, it's not the same binary as less).
  • Steve Bennett
    Steve Bennett about 12 years
    On OSX, more calls less, but apparently with different arguments (like quitting when you hit EOF).
  • iProgram
    iProgram almost 9 years
    Sometimes less is more!
  • törzsmókus
    törzsmókus over 6 years
    h: everything you don’t remember ;)