Linux more Command
The Linux more command is similar to cat, but it displays the content one page at a time, making it more convenient for users to read through the content page by page. The basic commands include pressing the space bar to display the next page, pressing the 'b' key to go back one page, and it also has a search functionality (similar to vi). For help on using the command, press 'h'.
Syntax
more [-dlfpcsu] [-num] [+/pattern] [+linenum] [fileNames..]
Parameters:
- -num: Number of lines to display at once
- -d: Prompts the user with [Press space to continue, 'q' to quit.] at the bottom of the screen. If the user presses the wrong key, it displays [Press 'h' for instructions.] instead of a beep sound
- -l: Disables pausing when encountering special character ^L (form feed)
- -f: Counts actual lines, not auto-wrapped lines (lines that are too long may be expanded into two or more lines)
- -p: Instead of scrolling, clears the screen and then displays the content
- -c: Similar to -p, but displays the content first and then clears the old data
- -s: Replaces multiple consecutive blank lines with one blank line
- -u: Does not display the underline (varies depending on the terminal specified by the TERM environment variable)
- +/pattern: Searches for the string (pattern) before displaying each file and starts displaying from the string
- +num: Starts displaying from the num line
- fileNames: The files to display content from, can be multiple
Example
Displays the content of testfile one page at a time, replacing multiple consecutive blank lines with one blank line.
more -s testfile
Displays the content of testfile starting from the 20th line.
more +20 testfile
Common Operation Commands
- Enter: Moves down n lines, default is 1 line
- Ctrl+F: Scrolls down one screen
- Space bar: Scrolls down one screen
- Ctrl+B: Returns to the previous screen
- =: Outputs the current line number
- :f: Outputs the file name and current line number
- V: Invokes the vi editor
- !command: Invokes the shell and executes the command
- q: Exits more