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.
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
TERMvariable 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
LINESvariable. Also, you can easily adjust the window capacity for each run of the command by adding the -n flag.Use the
MOREvariable to customize the more command with your preferred configuration each time the system starts. This variable accepts more command flags.
Flags
| 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 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
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:
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 hDisplays a help screen that describes the more subcommands. vStarts the vieditor, editing the current file in the current line.ror^LRefreshes the display. RRefreshes the display and removes buffered input. [ K](Spacebar)Moves forward Klines when you press the spacebar. If you do not give a value forK, pressing the spacebar displays the next full screen by default. This spacebar subcommand is the same as [K]for [K]^For [K]z.[ K]for [K]^For [K]zMoves forward Klines, or one full screen if you do not give a value forK.[ K]bor [K]^BMoves backward Klines, or one full screen if you do not give a value forK.[ K]dor [K]^DMoves forward Klines, or half a screen if you do not give a value forK. If you give a value forK, the more command sets thedanduscroll capacity toKlines for the session.[ K]uor [K]^UMoves backward Klines, or half a screen if you do not give a value forK. If you give a value forK, the more command sets thedanduscroll capacity toKlines for the session.[ K]jor [K](Enter) or [K]^EMoves forward Klines, or one line if you do not give a value forK.[ K]kor [K]^YMoves backward Klines, or one line if you do not give a value forK.[ K]gMoves to the beginning of the file, unless you give a line number for K. The default forKis line number 1.[ K]GMoves to the last line in the file, unless you give a line number for K. The default forKis the last line in the file.[ K]por [K]%Moves to the point in the file that is K%of the total file. The default forKis one percent, or the first line in the file.ma-zMarks 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 Kis 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 Kis 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 Kis 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 Kis the first occurrence.[ K]nRepeats the last search, specifying an occurrence of the pattern (or an occurrence not containing the pattern if the search subcommand included !). The default value forKis the first occurrence.:aLists the file or files that you named in the more command line. :for^Gor=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] orE[File]Examines the specified file, provided you named it in the more command line. [ K]:nor [K]NExamines either the next file (if you do not give a value for K) or the fileKnumber of positions forward in the list of files you named in the more command line.[ K]:por [K]PExamines either the previous file (if you do not give a value for K) or the fileKnumber of positions backward in the list of files you named in the more command line.:tTagstringDisplays 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 :tsubcommand is the interactive version of the -t flag.:qorqorQExits the more command. :!command or!commandStarts the specified command in a new shell. HToggles the search pattern highlighting feature on or off.
Exit status
This command returns the following exit values:
| Item | Description |
|---|---|
| 0 | Successful completion. |
| >0 | An error occurred. |
Examples
- To view a file named
myfile, enter the following command:more myfile - To view output from the nroff command, enter the following command:
ls -l | more - To view each file that starts at its last screen, enter the following command:
more -p G file1 file2 - To view each file with the 100th line at the current position, enter the following command:
more -p 100 file1 file2Typically, 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.
- To view each file that starts with the first line that contains the
foostring, enter the following command:more -p /foo file1 file2The more command displays the line in the current position, the third line on the screen.
Files
| Item | Description |
|---|---|
| /usr/share/lib/terminfo | Indicates the terminal information database. |