One linux Command every day (12): more command, linux Command 12 more
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 Format:
More [-dlfpcsu] [-num] [+/pattern] [+ linenum] [file...]
2. command functions:
The more command and cat command have the same functions as viewing the content in the file, but the difference is that more can view the content of the file by PAGE, and support direct jump to the line and other functions.
3. Command Parameters:
+ N is displayed from rows n of bytes.
-N defines the screen size as n rows
+/Pattern Search for the string (pattern) before each file is displayed, and then the string is displayed after the first two lines.
-C clear the screen from the top and then display
-D: Press space to continue, 'q' to quit (Press the space key to continue, Press the q key to exit )."
-L ignore Ctrl + l (page feed) characters
-P clears the window instead of scrolling the screen to change the page of the file, similar to the-c option.
-S: displays multiple consecutive empty rows as one row.
-U remove the offline lines in the file content
4. Common operation commands:
Enter down n rows, which need to be defined. The default value is 1 line.
Ctrl + F scroll down one screen
Space key scroll down one screen
Ctrl + B return to the previous screen
= Output the row number of the current row
: F output file name and the row number of the current row
V call vi Editor
! Command to call Shell and execute the command
Q: Exit more.
5. Command instance:
Instance 1: displays the content starting from row 3rd in the file.
Command:
More + 3 log2012.log
Output:
[root@localhost test]# cat log2012.log 2012-012012-022012-032012-04-day12012-04-day22012-04-day3======[root@localhost test]# more +3 log2012.log 2012-032012-04-day12012-04-day22012-04-day3======[root@localhost test]#
Instance 2: Find the first line with the "day3" string in the file and display the output from the first two lines.
Command:
More +/day3 log2012.log
Output:
[root@localhost test]# more +/day3 log2012.log ...skipping2012-04-day12012-04-day22012-04-day32012-052012-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-012012-022012-032012-04-day12012-04-day2
Note:
As shown in, the ratio of the content displayed on the screen to the total number of lines of the file is displayed at the bottom. Press Ctrl + F or the space key to display 5 items on the next screen, the percentage also changes.
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 pipelines |
Command:
Ls-l | more-5
Output:
[Root @ localhost test] # ls-l | more-5 total 36-rw-r -- r -- 1 root 308 11-01 16:49 log2012.log-rw-r -- 1 root 33 10 -28 log2013.log-rw-r -- 1 root 127 10-28 log2014.loglrwxrwxrwx 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 log.txt drwxr-xr-x 6 root 4096 10-27 058 scfdrwxrwxrwx 2 root 4096 10-28 test3drwxrwxrwxrwx 2 root 4096 10-28 test4
Description:
Five files are displayed on each page. Press Ctrl + F or the space bar to display the next five files.