more命令shell
功能說明
編輯器
Linux系統中,nl、cat、tac等命令,都是一次性將數據顯示到屏幕上面,more命令能夠進行一頁一頁翻動閱讀。還能夠按頁來查看文件內容,還支持直接跳轉到指定行等功能。用法以下:ide
more [options] file [...] |
命令參數ui
選項 | 含義 |
+n | 從第n行開始顯示 |
-n | 定義屏幕大小爲n行 |
+/pattern | 在每一個檔案顯示前搜尋該字串(pattern),而後從該字串前兩行以後開始顯示 |
-c | 從頂部清屏,而後顯示 |
-d | 提示「Press space to continue,’q’ to quit(按空格鍵繼續,按q鍵退出)」,禁用響鈴功能 |
-l | 忽略Ctrl+l(換頁)字符 |
-p | 經過清除窗口而不是滾屏來對文件進行換頁,與-c選項類似 |
-s | 把連續的多個空行顯示爲一行 |
-u | 把文件內容中的下畫線去掉 |
經常使用操做命令spa
|
示例
一頁一頁的翻
[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-- |