PDA

View Full Version : Do 'more' with 'less'


masterof_none
02-11-2003, 11:43 PM
No, I'm not promoting the Windows 2003 Server ;-)

Here, we're going to have a quick overview of two very important commands in *NIX , namely more and less

more and less are the commands in Linux/*nix to manipulate file (common would be to view it )and do more with it (thus the word more) in Unix.

But the difference between the two is that , the less is more powerful, and got more options than more

Sounds weird, eh?

To use them , we can just type at the command prompt:

[sawit:~]m0n% less random.txt

or

[sawit:~]m0n%more random.txt


see tha man page for more:


MORE(1)

NAME
more, page - file perusal filter for crt viewing

SYNOPSIS
more [ -cdflsu ] [ -n ] [ +linenumber ] [ +/pattern ] [
name ... ]

page more options

DESCRIPTION
More is a filter which allows examination of a continuous
text one screenful at a time on a soft-copy terminal. It
normally pauses after each screenful, printing the current
file name at the bottom of the screen or --More-- if input
is from a pipe. If the user then types a carriage return,
one more line is displayed. If the user hits a space,
another screenful is displayed. Other possibilities are
enumerated later.

and man page for less


LESS(1) LESS(1)

NAME
less - opposite of more

SYNOPSIS
less -?
less --help
less -V
less --version
less [-[+]aBcCdeEfgGiImMnNqQrsSuUVwX]
[-b bufs] [-h lines] [-j line] [-k keyfile]
[-{oO} logfile] [-p pattern] [-P prompt] [-t tag]
[-T tagsfile] [-x tab] [-y lines] [-[z] lines]
[+[+]cmd] [--] [filename]...
(See the OPTIONS section for alternate option syntax with
long option names.)

DESCRIPTION
Less is a program similar to more (1), but which allows
backward movement in the file as well as forward movement.
Also, 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.




If you see carefully, less has more options than more.

OK, now , we know a little bit about more and less

In the Next post, we'll explore the options of both two, and how can we do the piping with other commands.