Use of the linux more command

Source: Internet
Author: User

In linux, the more command is similar to cat. The cat command displays the content of the entire file on the screen from top to bottom. More will display one page at a time to facilitate users to read one page at a time. The most basic instruction is to press the space key to display it on the next page, and press the B key to return (back) one page is displayed, and the string search function is also available. The more command reads the file from the front and back, so the entire file is loaded at startup. 1. command syntax: more [-dlfpcsu] [-num] [+/pattern] [+ linenum] [file...] 2. command function: the more command and cat command are used to view the content in the file, but the difference is that more can view the content of the file by PAGE, and supports direct line navigation and other functions. 3. command Parameter: + n is displayed from rows minus n.-n is defined as n rows. +/pattern: search for the string (pattern) before each file is displayed ), then, from the first two lines of the string, the-c is displayed on the top of the screen, and the-d prompt is displayed, "Press space to continue, 'q' to quit (Press the space key to continue, press the q key to exit) ", disable the bell function-l ignore the Ctrl + l (for page feed) character-p by clearing the window rather than scrolling the screen to swap the file, similar to the-c option,-s displays multiple consecutive blank lines as one line.-u removes the offline lines in the file content. 4. common Operation Command: Enter n rows down, which needs to be defined. The default value is 1 line Ctrl + F scroll down one screen space key scroll down one screen Ctrl + B Return the previous screen = output the row number of the current line: f. The output file name and the row number V call the vi editor! Command to call Shell, and run the command q to exit more 5. command instance: instance 1: display the content starting from line 1 in the file. Command: more + 3 log2012.log output: [root @ localhost test] # cat log2012.log 2012-01 2012-02 2012-03 2012-04-day1 2012-04-day2 2012-04-day3 ====== [root @ localhost test] # more + 3 log2012.log 2012- 03 2012-04-day1 2012-04-day2 2012-04-day3 ==== [root @ localhost test] # instance 2: find the first line with the "day3" string in the file, and display the output command: more +/day3 log2012.log output: [root @ localhost test] from the first two lines. # More +/day3 log2012.log... skipping 2012-04-day1 2012-04-day2 2012-04-day3 2012-05 2012-05-day1 ===== [root @ localhost test] # instance 3: set the number of lines displayed on each screen command: more-5 log2012.log output: [root @ localhost test] # more-5 log2012.log 2012-01 2012-02 2012-03 2012-04-day1 2012-04-day2 note, at the bottom, the ratio of the content displayed on the screen to the total number of lines of the file is displayed. Press Ctrl + F or the space key to display 5 items on the next screen, and the percentage will also change. Example 4: List files in a directory. Because there are too many contents, we should learn to use more for paging display. This must be combined with the pipeline | command: ls-l | more-5 output: [root @ localhost test] # ls-l | more-5 total 36-rw-r -- 1 root 308 11-01 49 log2012.log-rw-r -- 1 root 33 10-28 log2013.log-rw-r -- 1 root 127 10-28 log2014.log lrwxrwxrwx 1 root 7 10-28 log_link.log-> log. log-rw-r -- 1 root 25 10-28 17:02 log. log-rw-r -- 1 root 37 10-28 :07 log.txt drwxr-xr-x 6 r Oot root 4096 10-27 scf drwxrwxrwx 2 root 4096 10-28 test3 drwxrwxrwx 2 root 4096 10-28 test4 Description: five files are displayed on each page, press Ctrl + F or the space key to display the next five files.
 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.