[ Next Article | Previous Article | Book Contents | Library Home | Legal | Search ]
Commands Reference, Volume 3

more or page Command

Purpose

Displays the contents of files one screen at a time.

Syntax

{ more | page } [ -c ] [ -d ] [ -e ] [ -i ] [ -l ] [ -N ] [ -s ] [ -u ] [ -v ] [ -z ] [ -n Number ] [ -p Subcommand ] [ -t Tagstring ] [ -W Option ] [ -x Tabs ] [ File ... ]

Description

The more and page commands are nearly identical. The more command scrolls each new screen, and the page command clears each screen before displaying a new one. Although the balance of this document mentions only the more command, nearly all information applies equally to the page command. The exceptions are descriptions of moving through a file: the more command scrolls and the page command jumps.

Note: On some terminal models, the more command clears the screen, instead of scrolling.

The more command reads files and displays the text one screen at a time. The command pauses after each screen and prints the word More at the bottom of the screen. If you then press a carriage return, the more command displays an additional line. If you press the space bar, the more command displays another full screen of text.

Instead of naming files to read, you can either redirect or pipe standard output, such as a long directory listing, to the more command. The command adds a % (percent sign) to its prompt when reading from a file rather than a pipe. This provides the percentage of the file (in characters, not lines) that the more command has read.

Environment Variables

Environment variables affect the way the more command works. You can set some environment characteristics in the /etc/environment file and system profile files, such as the .ksh, .csh, and .profile files. Refer to "User Environment and System Information Overview" in AIX Version 4.3 System User's Guide: Operating System and Devices for discussions about determining and configuring your system environment.

The more command uses the TERM variable to determine terminal characteristics. If this variable is NULL or not set, the command uses the default terminal type. The /usr/share/lib/terminfo directory contains definitions for terminal characteristics.

By default, the more command window size is 2 lines less than what the system terminal is capable of. The command sets the default window size based on the LINES variable. Also, you can easily adjust the window size for each run of the command by adding the -n flag.

Use the MORE variable to customize the more command with your preferred configuration each time the system starts. This variable accepts more command flags.

Flags

-c Prevents the screen from scrolling, which makes text easier to read as the more command writes to the screen. The system ignores the -c flag if the terminal cannot clear to the end of a line.
-d Prints a message, appended to the More prompt at the bottom of the screen, about which keys continue, quit, and provide help for the more command.
-e Exits automatically after displaying the last line of the last file.
-i Searches for patterns without considering uppercase and lowercase.
-l Pauses after detecting a page break in the input.
-N Suppresses line numbering. The default display, with line numbers, can slow the more command's performance on very large input files. The line numbering feature displays the line number in the = subcommand and passes the line number to the editor (if it is the vi editor).
-n Number Configures the more command to display the specified number of lines in the window. Without the -n flag, the more command defaults to two lines less than what the terminal is capable of. For example, on a 24-line terminal, the default is 22 lines.
-p Subcommand Starts the more command and specified subcommand for each File operand. For example, more -p 50j text1 text2 displays the text1 file at the fiftieth line; then does the same for the text2 file when you finish the first. See "Subcommands" for descriptions of more subcommands.
-s Reduces multiple blank lines in the output to only one blank line. The -s flag is particularly helpful in viewing output from the nroff command.
-t Tagstring Displays the portion of the file that contains the specified tag. This flag works only on files containing tags created with the ctags command.
-u Prevents the more command from underlining or creating reverse video text for underlined information in a source file. The -u flag also forces the more command to recognize a carriage-return character, if it exists, at the end of a line.
-v Suppresses the graphical translation of nonprinting characters. Without the -v flag, the more command graphically interprets all non-ASCII and most control characters, except Tab, Backspace, and Return. For example, if you do not use the -v flag, the more command displays the non-ASCII characters Ctrl-x as ^X and x as M-x.
-W Option Provides the specified Option to the more command as an extension:
notite Prevents the more command from sending the terminal initialization string (either the ti termcap or the smcup terminfo capability) before displaying the file. This option also prevents the more command from sending the terminal de-initialization string (either the te termcap or the rmcup terminfo capability) before exiting.
tite Causes the more command to send the initialization and de-initialization strings. This is the default.

These options control whether the more command sends the initialization strings described, which, for certain terminals (such as some xterms), cause the more command to switch to an alternative screen. The effect of switching screens is to erase the display of the file you were viewing.

-x Tabs Sets tab stops at the specified Tabs position. The default tab setting is 8 columns.
-z Graphically displays the Tab, Backspace, and Return control characters. With the -z flag, the more command translates the Backspace character as ^H, Return as ^M, and Tab as ^I.

Subcommands

The more command accepts subcommands when the command pauses and as parameters for the -p flag. Many subcommands take an optional integer, symbolized here by K, which you must enter before the subcommand, with no space between. The more command, in the paused state, processes subcommands immediately and does not require you to press the Enter key.

The more command uses the following subcommands:

h Displays a help screen that describes the more subcommands.
v Starts the vi editor, editing the current file.
r or ^L Refreshes the display.
R Refreshes the display and removes buffered input.
[K](Spacebar) Moves forward K lines when you press the spacebar. If you do not give a value for K, pressing the spacebar displays the next full screen by default. This spacebar subcommand is the same as [K]f or [K]^F or [K]z.
[K]f or [K]^F or [K]z
Moves forward K lines, or one full screen if you do not give a value for K.
[K]b or [K]^B Moves backward K lines, or one full screen if you do not give a value for K.
[K]d or [K]^D Moves forward K lines, or half a screen if you do not give a value for K. If you give a value for K, the more command sets the d and u scroll size to K lines for the session.
[K]u or [K]^U Moves backward K lines, or half a screen if you do not give a value for K. If you give a value for K, the more command sets the d and u scroll size to K lines for the session.
[K]j or [K](Enter) or [K]^E
Moves forward K lines, or one line if you do not give a value for K.
[K]k or [K]^Y Moves backward K lines, or one line if you do not give a value for K.
[K]g Moves to the beginning of the file, unless you give a line number for K. The default for K is line number 1.
[K]G Moves to the last line in the file, unless you give a line number for K. The default for K is the last line in the file.
[K]p or [K]% Moves to the point in the file that is K percent of the total file. The default for K is one percent, or the first line in the file.
ma-z Marks the current position in the file with the specified letter.
'a-z (Single quote) Moves to the position marked with the specified letter.
'' (Two single quotes) Returns to the position from which the last large movement (moving more than a page) command was run. If no such movements have been made, returns to the beginning of the file.
[K]/pattern (Slash) Searches forward, from the current position, for the specified occurrence of the specified pattern of characters. The default value for K is the first occurrence.
[K]/!pattern (Slash, exclamation mark) Searches forward, from the current position, for the specified occurrence of a line that does not contain the specified pattern of characters. The default value for K is the first occurrence.
[K]?pattern (Question mark) Searches backward, from the current position, for the specified occurrence of the specified pattern of characters. The default value for K is the first occurrence.
[K]?!pattern (Question mark, exclamation mark) Searches backward, from the current position, for the specified occurrence of a line that does not contain the specified pattern of characters. The default value for K is the first occurrence.
[K]n Repeats the last search, specifying an occurrence of the pattern (or an occurrence not containing the pattern if the search subcommand included !). The default value for K is the first occurrence.
:a Lists the file or files you named in the more command line.
:f or ^G or = Displays information about the current file:
  • file name
  • order of the file in the list of files
  • current line number
  • current position in the file, given as a percentage
  • current byte number and total bytes to display.
:e[File] or E[File] Examines the specified file, provided you named it in the more command line.
[K]:n or [K]N Examines either the next file (if you do not give a value for K) or the file K number of positions forward in the list of files you named in the more command line.
[K]:p or [K]P Examines either the previous file (if you do not give a value for K) or the file K number of positions backward in the list of files you named in the more command line.
:t Tagstring Displays the portion of the file that contains the specified tag. This subcommand works only on files containing tags created with the ctags command. The :t subcommand is the interactive version of the -t flag.
:q or q or Q Exits the more command.
:!command or !command
Starts the specified command in a new shell.

Exit Status

This command returns the following exit values:

0 Successful completion.
>0 An error occurred.

Examples

  1. To view a file named myfile, enter:
    more myfile
  2. To view output from the nroff command, enter:
    ls -l | more
  3. To view each file starting at its last screen, enter:
    more -p G file1 file2
  4. To view each file with the 100th line at the current position, enter:
    more -p 100 file1 file2
    Typically, the current position in a more command display is the third line on the screen. In this example, the first line on the screen is the 98th line in the file.
  5. To view each file starting with the first line that contains the foo string, enter:
    more -p foo file1 file2
    The more command displays the line in the current position, the third line on the screen.

Files

/usr/share/lib/terminfo Indicates the terminal information database.

Related Information

The cat command, csh command, ctags command, ksh command, msgs command, pg command, script command.

The environment file, terminfo file.

User Environment and System Information Overview in the AIX Version 4.3 System User's Guide: Operating System and Devices.

Understanding Locale Environment Variables in the AIX Version 4.3 System Management Concepts: Operating System and Devices.

Shells Overview in the AIX Version 4.3 System User's Guide: Operating System and Devices.

Input and Output Redirection Overview in AIX Version 4.3 System User's Guide: Operating System and Devices.

Files Overview in the AIX Version 4.3 System User's Guide: Operating System and Devices.

File and Directory Access Modes in the AIX Version 4.3 System Management Guide: Operating System and Devices.


[ Next Article | Previous Article | Book Contents | Library Home | Legal | Search ]