more Command

Purpose

Displays file contents one screen at a time.

Syntax

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

Description

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

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

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 it reads from a file rather than a pipe. This option provides the percentage of the file (in characters, not lines) that the more command read.

The more command sets the terminal to NOECHO mode so the output can be continuous. Except for the / and ! subcommands, commands that are typed do not normally show up on the terminal. If the standard output is not a terminal, the more command acts just like the cat command, except that a header is printed before each file in a series.

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.

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 capacity is 2 lines less than what the system terminal is capable of. The command sets the default window capacity based on the LINES variable. Also, you can easily adjust the window capacity 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

Table 1. Flags. Flags Description
Item Description
-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, which is appended to the More prompt at the screen, about which keys continue, quit, and provide help for the more command. Displays error messages rather than ringing the terminal bell if an unrecognized command is used. This option is helpful for inexperienced users.
-e Exits automatically after is displays the last line of the last file.
-H Disables the search pattern that highlights the feature by default.
-i Searches for patterns without considering uppercase and lowercase.
-l Pauses after it detects a page break in the input. If the -l flag is not used, the more command pauses to accept commands after any line that contains a ^L (Ctrl-L) character. Also, if a file begins with a FORMFEED, the screen is cleared before the file is printed.
-N Suppresses line numbering. The default display, with line numbers, can slow the performance of the more command on 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. The -n option overrides any values that are obtained from the environment.
-p Subcommand

Starts the more command and specified subcommand for each File operand. For example, the more -p 50j text1 text2 command displays the text1 file at the 50th line, then does the same for the text2 file when you finish the first. See "Subcommands" for descriptions of more subcommands.

If the command is a positioning command, such as a line number or a regular expression search, set the current position to represent the final results of the command, without writing any intermediate lines of the file. For example, the following commands are functionally the same and starts the display with the current position at line 1000, passing the lines that j writes and scrolls off the screen if it is issued during the file examination:

more -p 1000j filename
more -p 1000G filename

If the positioning command is unsuccessful, the first line in the file will be the current position.

-s Reduces multiple blank lines in the output to only one blank line. The -s flag is 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 that contain tags that are created with the ctags command.
-u Prevents the more command from treating a backspace character as a printable control character (displayed as a ^H (Ctrl-H)), suppressing backspacing, 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 it displays 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 it exits.
tite
Causes the more command to send the initialization and de-initialization strings. This option is the default.

These options control whether the more command sends the initialization strings that are 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, which is 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:

Table 2. Subcommands of more command. more command
Item Description
h Displays a help screen that describes the more subcommands.
v Starts the vi editor, editing the current file in the current line.
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 capacity 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 capacity 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% 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 quotation mark) Moves to the position marked with the specified letter.
'' (Two single quotation marks) Returns to the position from which the last large movement (moving more than a page) command was run. If no such movements are 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 that 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, which is 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 that contain tags that are 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.
H Toggles the search pattern highlighting feature on or off.

Exit status

This command returns the following exit values:

Table 3. Exit status. Exit Status
Item Description
0 Successful completion.
>0 An error occurred.

Examples

  1. To view a file named myfile, enter the following command:
    more myfile
  2. To view output from the nroff command, enter the following command:
    ls -l | more
  3. To view each file that starts at its last screen, enter the following command:
    more -p G file1 file2
  4. To view each file with the 100th line at the current position, enter the following command:
    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 that starts with the first line that contains the foo string, enter the following command:
    more -p /foo file1 file2

    The more command displays the line in the current position, the third line on the screen.

Files

Table 4. Files. Files
Item Description
/usr/share/lib/terminfo Indicates the terminal information database.