Open In App

more command in Linux with Examples

more command is used to view the text files in the command prompt, displaying one screen at a time in case the file is large (For example log files). The more command also allows the user do scroll up and down through the page. The syntax along with options and command is as follows. Another application of more is to use it with some other command after a pipe. When the output is large, we can use more command to see output one by one.

Syntax:



more [-options] [-num] [+/pattern] [+linenum] [file_name]

  • [-options]: any option that you want to use in order to change the way the file is displayed. Choose any one from the followings: (-d, -l, -f, -p, -c, -s, -u)
  • [-num]: type the number of lines that you want to display per screen.
  • [+/pattern]: replace the pattern with any string that you want to find in the text file.
  • [+linenum]: use the line number from where you want to start displaying the text content.
  • [file_name]: name of the file containing the text that you want to display on the screen.

While viewing the text file use these controls:



Enter key: to scroll down line by line.
Space bar: To go to the next page.
b key: To go to back one page.

Options:

Using more to Read Long Outputs: We use more command after a pipe to see long outputs. For example, seeing log files, etc.

cat a.txt | more
Article Tags :