(turn) more command

Original: http://www.cnblogs.com/peida/archive/2012/11/02/2750588.html

 

The more command is similar in function to cat . The cat command displays the contents of the entire file on the screen from top to bottom. more will be displayed page by page for users to read page by page, and the most basic command is to press the space key (space) to display the next page, and press the b key to display one page back, and There is also a search string function  . The more command reads the file from front to back, so the entire file is loaded at startup .

1. Command format:

more [-dlfpcsu ] [-num ] [+/ pattern] [+ linenum] [file ... ] 

2. Command function:

The more command has the same function as cat to view the contents of the file, but the difference is that more can view the contents of the file by page, and also supports functions such as direct jumping of lines.

3. Command parameters:

+n  display from the nth line     

-n  defines the screen size as n lines      

+/pattern searches for the string (pattern) before each file is displayed, then starts displaying after  the first two lines of the string 

-c  clear the screen from the top, then show      

-d  prompts "Press space to continue, 'q' to quit (press space to continue, press q to quit)", disable the bell function      

-l  ignores Ctrl+l (form feed) characters       

-p  pages the file by clearing the window instead of scrolling, similar to the -c option      

-s  display consecutive multiple blank lines as one line      

- remove the underline from the file content      

4. Common operating commands:

Enter   goes down n lines, needs to be defined. Default is 1 line  

Ctrl+F  scroll down one screen  

Spacebar to   scroll down one screen

Ctrl+B   to return to the previous screen

=        output the line number of the current line

:f      output file name and line number of current line

V invoke vi editor

The ! command    invokes the shell and executes the command 

q        quitmore

5. Command example:

Example 1: Display the contents of the file starting from line 3

Order:

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]#

 

实例2:从文件中查找第一个出现"day3"字符串的行,并从该处前两行开始显示输出 

命令:

 more +/day3 log2012.log

输出:

[root@localhost test]# more +/day3 log2012.log 

...skipping

2012-04-day1

2012-04-day2

2012-04-day3

2012-05

2012-05-day1

 

======[root@localhost test]#

 

实例3:设定每屏显示行 

命令:

more -5 log2012.log

输出:

[root@localhost test]# more -5 log2012.log 

2012-01

2012-02

2012-03

2012-04-day1

2012-04-day2

说明:

如下图所示,最下面显示了该屏展示的内容占文件总行数的比例,按 Ctrl+F 或者 空格键 将会显示下一屏5条内容,百分比也会跟着变化。

实例4:列一个目录下的文件,由于内容太多,我们应该学会用more来分页显示。这得和管道 | 结合起来 

命令:

ls -l  | more -5

输出:

[root@localhost test]#  ls -l  | more -5

总计 36

-rw-r--r-- 1 root root  308 11-01 16:49 log2012.log

-rw-r--r-- 1 root root   33 10-28 16:54 log2013.log

-rw-r--r-- 1 root root  127 10-28 16:51 log2014.log

lrwxrwxrwx 1 root root    7 10-28 15:18 log_link.log -> log.log

-rw-r--r-- 1 root root   25 10-28 17:02 log.log

-rw-r--r-- 1 root root   37 10-28 17:07 log.txt

drwxr-xr-x 6 root root 4096 10-27 01:58 scf

drwxrwxrwx 2 root root 4096 10-28 14:47 test3

drwxrwxrwx 2 root root 4096 10-28 14:47 test4

 

说明:

每页显示5个文件信息, Ctrl+F 或者 空格键 将会显示下5条文件信息。

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326692967&siteId=291194637