more command tutorial in linux/unix with examples and use cases

linux more command – a filter for paging through text one screenful at a time.

The linux more command, usually used when browsing the contents of large files, can help us quickly flip through the text in split screens.

The current Ubuntu version (19.04) less is a program similar to more.

Syntax

more [options] file...

Options

  • -d
    Prompt with “[Press space to continue, ‘q’ to quit.]”, and display “[Press ‘h’ for instructions.]” instead of ringing the bell when an illegal key is pressed.
  • -l
    Do not pause after any line containing a ^L (form feed).
  • -f
    Count logical lines, rather than screen lines (i.e., long lines are not folded).
  • -p
    Do not scroll. Instead, clear the whole screen and then display the text. Notice that this option is switched on automatically if the executable is named page.
  • -c
    Do not scroll. Instead, paint each screen from the top, clearing the remainder of each line as it is displayed.
  • -s
    Squeeze multiple blank lines into one.
  • -u
    Suppress underlining.
  • -number
    The screen size to use, in number of lines.
  • +number
    Start displaying each file at line number.
  • +/string
    The string to be searched in each file before starting to display it.

Interactive Commands

Interactive commands for more are based on vi.

  • <space>
    Display next k lines of text [current screen size]
  • z
    Display next k lines of text [current screen size]*
  • <return>
    Display next k lines of text [1]*
  • d or ctrl-D
    Scroll k lines [current scroll size, initially 11]*
  • q or Q or
    Exit from more
  • s
    Skip forward k lines of text [1]
  • f
    Skip forward k screenfuls of text [1]
  • b or ctrl-B
    Skip backwards k screenfuls of text [1]

  • Go to place where previous search started
  • =
    Display current line number
  • /
    Search for kth occurrence of regular expression [1]
  • n
    Search for kth occurrence of last r.e [1]
  • ! or :!
    Execute in a subshell
  • v
    Start up /usr/bin/vi at current line
  • ctrl-L
    Redraw screen
  • :n
    Go to kth next file [1]
  • :p
    Go to kth previous file [1]
  • :f
    Display current file name and line number
  • .
    Repeat previous command

Examples & Use Cases

Display file contents starting at line X

Skip the file header and display the file contents from line 20

➜  ~ more +20 install.sh

Two consecutive blank lines are displayed as one blank line

➜  ~ more -s install.sh

Search for strings in files and display

➜  ~ more +/install install.sh

Use the more command to pipe through long content

➜  ~ cat install.sh | more

Best linux commands articles:

Linux common commands tutorial and use examples
Sed command tutorials in linux/unix with examples and use cases
Awk command tutorials in linux/unix with examples and use cases

Add a Comment

Your email address will not be published. Required fields are marked *