CartMetrix - Do you know yours?

« Kill a Specific Process of a Specific User | Home | Racism Issues and Perspective »

10/25/2005

Less vs More

Less and more are two Unix command line tools for paging through large files, viewing the output from commands, searching logfiles, viewing man pages, etc.

Less can do everything that more can plus it can do more and it can do it better. Its like more v2, better thought out. Not only with more features, but better implemented base featues. Both can page through files forward (f) or backward (b). Both allow searching and some form of regular expression matching.

Less can read some binary files, like tar archives and RPMs (try a less somefile.tar.gz to see a listing of the filenames contained in the archive).

With less you can pass a text file directly off to vim at the current line for a quick edit and then back less when complete.

To use less as your default pager (for man files etc.) add this to your .bashrc:

export PAGER='less'

less

NAME
       less - opposite of more

SYNOPSIS
       less [-[+]aBcCdeEfFgGiIJKmMnNqQrRsSuUVwWXZ~]
            [-b space] [-h lines] [-j line] [-k keyfile]
            [-K character set] [-{oO} logfile]
            [-p pattern] [-P prompt] [-t tag]
            [-T tagsfile] [-x tab,...] [-y lines] [-[z] lines]
            [-# shift] [+[+]cmd] [--] [filename]... 

                           MOVING

  e  ^E  j  ^N  CR  *  Forward  one line   (or N lines).
  y  ^Y  k  ^K  ^P  *  Backward one line   (or N lines).
  f  ^F  ^V  SPACE  *  Forward  one window (or N lines).
  b  ^B  ESC-v      *  Backward one window (or N lines).
  z                 *  Forward  one window (and set window to N).
  w                 *  Backward one window (and set window to N).
  ESC-SPACE         *  Forward  one window, but don't stop at end-of-file.
  d  ^D             *  Forward  one half-window (and set half-window to N).
  u  ^U             *  Backward one half-window (and set half-window to N).
  ESC-(  RightArrow *  Left  one half screen width (or N positions).
  ESC-)  LeftArrow  *  Right one half screen width (or N positions).
  F                    Forward forever; like "tail -f".
  r  ^R  ^L            Repaint screen.
  R                    Repaint screen, discarding buffered input.

                         SEARCHING

  /pattern          *  Search forward for (N-th) matching line.
  ?pattern          *  Search backward for (N-th) matching line.
  n                 *  Repeat previous search (for N-th occurrence).
  N                 *  Repeat previous search in reverse direction.  

                           JUMPING

  g  < ESC-<       *  Go to first line in file (or line N).
  G  >  ESC->       *  Go to last line in file (or line N).
  p  %              *  Go to beginning of file (or N percent into file).
  t                 *  Go to the (N-th) next tag.
  T                 *  Go to the (N-th) previous tag.
  {  (  [           *  Find close bracket } ) ].
  }  )  ]           *  Find open bracket { ( [.

Popularity: 12%

Trackback:

Related Posts

  • No related posts

Post your opinion

Verification Image

Please type the letters you see in the picture.

Subscribe without commenting


damonparker.org is proudly powered by WordPress
Entries (RSS) and Comments (RSS).

copyright © 2002-2009 damonparker.org. all rights reserved.

Close
E-mail It