Linux系统中,nl、cat、tac等命令,都是一次性将数据显示到屏幕上面,more命令可以进行一页一页翻动阅读。还可以按页来查看文件内容,还支持直接跳转到指定行等功能。

1.命令格式:

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

2.命令参数:

   +n       从第n行开始显示

   -n       定义屏幕大小为n行

   +/pattern 在每个档案显示前搜寻该字串(pattern),然后从该字串前两行之后开始显示  

   -c       从顶部清屏,然后显示

   -d       提示“Press space to continue,’q’ to quit(按空格键继续,按q键退出)”,禁用响铃功能

   -l       忽略Ctrl+l(换页)字符

   -p       通过清除窗口而不是滚屏来对文件进行换页,与-c选项相似

   -s       把连续的多个空行显示为一行

   -u       把文件内容中的下画线去掉

3.常用操作命令:

   Enter    向下n行,需要定义。默认为1行

   Ctrl+F   向下滚动一屏

   空格键   向下滚动一屏

   Ctrl+B   返回上一屏

   =        输出当前行的行号

   :f      立即显示出文件名以及目前显示的行数

   V        调用vi编辑器

   !命令    调用Shell,并执行命令 

   q        退出more

命令示例:

1.一页一页的翻

[root@w zdw]# more /etc/man.config # If no catdir is given, it is assumed to be equal to the mandir# (so that this dir has both man1 etc. and cat1 etc. subdirs).# This is the traditional Unix setup.--More--(16%)  重点在这行

如果more后面接的文件内容行数大于屏幕输出的行数时,就会出现类似上面的显示。最后一行会显示出目前显示的百分比。

2.从第2行显示内容

[root@w zdw]# cat 123.logabcdefgh[root@w zdw]# more +2 123.logbcdefgh

3.查找第一个出现“d”字符串的行,并从该处前两行开始显示输出

[root@w zdw]# more +/d 123.log...skippingbcdefgh

4.设定每屏显示5行

[root@w zdw]# more -5 /etc/man.config ## Generated automatically from man.conf.in by the# configure script.## man.conf from man-1.6f--More--(2%)

下方显示了内容占文件总行数的比例,按空格键 将会显示下一屏5行内容,百分比也会随着变化

5.内容过多时,配和管道|,使用more来分页显示

[root@w zdw]# ls -ltotal 16drwxr-xr-x. 2 root root 4096 Apr 19 09:41 1-rw-r--r--. 1 root root   16 Apr 19 13:14 123.logdrwxr-xr-x. 2 root root 4096 Apr 19 09:41 2drwxr-xr-x. 2 root root 4096 Apr 19 09:41 3-rw-r--r--. 1 root root    0 Apr 19 13:49 test1-rw-r--r--. 1 root root    0 Apr 19 13:49 test2-rw-r--r--. 1 root root    0 Apr 19 13:49 test3-rw-r--r--. 1 root root    0 Apr 19 13:50 test4-rw-r--r--. 1 root root    0 Apr 19 13:50 test5[root@w zdw]# ls -l|more -3                         使用参数后只显示3行内容total 16drwxr-xr-x. 2 root root 4096 Apr 19 09:41 1-rw-r--r--. 1 root root   16 Apr 19 13:14 123.log--More--

学习自: