more
命令,功能類(lèi)似 cat
,cat
命令是整個(gè)文件的內(nèi)容從上到下顯示在屏幕上。more
會(huì)以一頁(yè)一頁(yè)的顯示方便使用者逐頁(yè)閱讀,而最基本的指令就是按空白鍵(space
)就往下一頁(yè)顯示,按 b
鍵就會(huì)往回(back)一頁(yè)顯示,而且還有搜尋字串的功能 。more
命令從前向后讀取文件,因此在啟動(dòng)時(shí)就加載整個(gè)文件。
more [-dlfpcsu ] [-num ] [+/ pattern] [+ linenum] [file ... ]
more
命令和cat
的功能一樣都是查看文件里的內(nèi)容,但有所不同的是more
可以按頁(yè)來(lái)查看文件的內(nèi)容,還支持直接跳轉(zhuǎn)行等功能。
+n
從笫n行開(kāi)始顯示-n
定義屏幕大小為n
行+/pattern
在每個(gè)檔案顯示前搜尋該字串(pattern),然后從該字串前兩行之后開(kāi)始顯示 -c
從頂部清屏,然后顯示-d
提示“Press space to continue,’q’ to quit(按空格鍵繼續(xù),按q鍵退出)”,禁用響鈴功能-l
忽略Ctrl+l
(換頁(yè))字符-p
通過(guò)清除窗口而不是滾屏來(lái)對(duì)文件進(jìn)行換頁(yè),與-c選項(xiàng)相似-s
把連續(xù)的多個(gè)空行顯示為一行-u
把文件內(nèi)容中的下畫(huà)線去掉Enter
向下n
行,需要定義。默認(rèn)為1
行Ctrl+F
向下滾動(dòng)一屏Ctrl+B
返回上一屏=
輸出當(dāng)前行的行號(hào):f
輸出文件名和當(dāng)前行的行號(hào)V
調(diào)用vi
編輯器!
命令, 調(diào)用Shell,并執(zhí)行命令 q
退出more顯示文件中從第3
行起的內(nèi)容
命令:
more +3 log.log
輸出:
從文件中查找第一個(gè)出現(xiàn)”line 5
“字符串的行,并從該處前兩行開(kāi)始顯示輸出
命令:
more +/line5 log.log
輸出:
this is line 4.
this is line5.
this is line 6.
this is line 7.
this is line 8.
this is line 9.
this is line 10.
this is line 11.
this is line 12.
this is line 13.
this is line 14.
this is line 15.
this is line 16.
this is line 17.
this is line 18.
--More--(76%)
設(shè)定每屏顯示行數(shù)
命令:
more -5 log.log
輸出:
[yiibai@localhost test]$ more -5 log.log
this is line 1.
this is line 2.
this is line 3.
this is line 4.
--More--(16%)
說(shuō)明:如上面所示
--More--(16%)
,最下面顯示了該屏展示的內(nèi)容占文件總行數(shù)的比例,按Ctrl+F
或者 空格鍵 將會(huì)顯示下一屏5條內(nèi)容,百分比也會(huì)跟著變化。
列一個(gè)目錄下的文件,由于內(nèi)容太多,所以應(yīng)該學(xué)會(huì)用more來(lái)分頁(yè)顯示。這得和管道 | 結(jié)合起來(lái)
命令:
ls -l | more -5
輸出:
[yiibai@localhost /]$ pwd
/
[yiibai@localhost /]$ ls -l | more -5
total 20
lrwxrwxrwx. 1 root root 7 Feb 12 22:20 bin -> usr/bin
dr-xr-xr-x. 4 root root 4096 Feb 12 22:32 boot
drwxr-xr-x. 20 root root 3240 Feb 13 19:38 dev
drwxr-xr-x. 78 root root 8192 Feb 13 19:29 etc
drwxr-xr-x. 3 root root 20 Feb 12 22:29 home
lrwxrwxrwx. 1 root root 7 Feb 12 22:20 lib -> usr/lib
lrwxrwxrwx. 1 root root 9 Feb 12 22:20 lib64 -> usr/lib64
drwxr-xr-x. 2 root root 6 Nov 5 11:38 media
--More--
說(shuō)明:每頁(yè)顯示
5
個(gè)文件信息,按Ctrl+F
或者 空格鍵 將會(huì)顯示下5條文件信息。