本文共 1463 字,大约阅读时间需要 4 分钟。
more命令
功能说明
Linux系统中,nl、cat、tac等命令,都是一次性将数据显示到屏幕上面,more命令可以进行一页一页翻动阅读。还可以按页来查看文件内容,还支持直接跳转到指定行等功能。用法如下:
more [options] file [...] |
命令参数
选项 | 含义 |
+n | 从第n行开始显示 |
-n | 定义屏幕大小为n行 |
+/pattern | 在每个档案显示前搜寻该字串(pattern),然后从该字串前两行之后开始显示 |
-c | 从顶部清屏,然后显示 |
-d | 提示“Press space to continue,’q’ to quit(按空格键继续,按q键退出)”,禁用响铃功能 |
-l | 忽略Ctrl+l(换页)字符 |
-p | 通过清除窗口而不是滚屏来对文件进行换页,与-c选项相似 |
-s | 把连续的多个空行显示为一行 |
-u | 把文件内容中的下画线去掉 |
常用操作命令
|
示例
一页一页的翻
[root@c6 ~]# more /etc/man.config ..........省略多行 MANPATH /usr/local/man MANPATH /usr/local/share/man MANPATH /usr/X11R6/man # # Uncomment if you want to include one of these by default --More--(34%) #重点在这行 如果more后面接的文件内容行数大于屏幕输出的行数时,就会出现类似上面的显示。最后一行会显示出目前显示的百分比。 |
从第2行显示内容
[root@c7 shell]# cat 123.log a b c d e f g h [root@c7 shell]# more +2 123.log #从第二行b开始显示内容 b c d e f g h |
查找第一个出现“e”字符串的行,并从该处前两行开始显示输出
[root@c6 shell]# more +/e 123.log ...skipping c d e f g h |
设定每屏显示5行
[root@c6 shell]# more -5 /etc/man.config # # Generated automatically from man.conf.in by the # configure script. # # man.conf from man-1.6f --More--(2%) 下方显示了内容占文件总行数的比例,按空格键 将会显示下一屏5行内容,百分比也会随着变化 |
内容过多时,配和管道|,使用more来分页显示
[root@c6 shell]# ls -l | more -3 #使用参数后只显示3行内容,按空格键显示后面内容 total 76 -rw-r--r--. 1 root root 14 Nov 9 05:51 123.log -rw-r--r--. 1 root root 314 Oct 12 07:05 1.sh --More-- |
本文转自cix123 51CTO博客,原文链接:http://blog.51cto.com/zhaodongwei/1870204,如需转载请自行联系原作者