鍍金池/ 教程/ Linux/ more命令
which命令
ss命令
cp命令使用示例
ps命令
find命令
grep命令
scp命令
rmdir命令
df命令示例
less命令
du命令示例
chown命令示例
route命令
ping命令
more命令
mv命令
ln命令
mkdir命令
rm命令
find命令常用參數(shù)示例
cat命令
find命令-xargs參數(shù)
touch命令
traceroute命令
gzip命令示例
date命令
ls命令
vmstat命令
lsof命令
diff命令
head命令
watch命令
ifconfig命令
cd命令
tail命令
iostat命令
chgrp命令示例
free命令
find命令-exec參數(shù)
tar命令打包解壓示例
cal命令
at命令
netstat命令
wc命令
chmod命令示例
pwd命令
top命令詳解示例
crontab命令(Linux定時(shí)任務(wù))
whereis命令
Linux命令大全教程
nl命令
rcp命令
locate命令

more命令

more命令,功能類(lèi)似 cat ,cat命令是整個(gè)文件的內(nèi)容從上到下顯示在屏幕上。more會(huì)以一頁(yè)一頁(yè)的顯示方便使用者逐頁(yè)閱讀,而最基本的指令就是按空白鍵(space)就往下一頁(yè)顯示,按 b 鍵就會(huì)往回(back)一頁(yè)顯示,而且還有搜尋字串的功能 。more命令從前向后讀取文件,因此在啟動(dòng)時(shí)就加載整個(gè)文件。

1.命令格式

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

2.命令功能

more命令和cat的功能一樣都是查看文件里的內(nèi)容,但有所不同的是more可以按頁(yè)來(lái)查看文件的內(nèi)容,還支持直接跳轉(zhuǎn)行等功能。

3.命令參數(shù)

  • +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à)線去掉

4.常用操作命令

  • Enter 向下n行,需要定義。默認(rèn)為1
  • Ctrl+F 向下滾動(dòng)一屏
  • 空格鍵 向下滾動(dòng)一屏
  • Ctrl+B 返回上一屏
  • = 輸出當(dāng)前行的行號(hào)
  • :f 輸出文件名和當(dāng)前行的行號(hào)
  • V 調(diào)用vi編輯器
  • ! 命令, 調(diào)用Shell,并執(zhí)行命令
  • q 退出more

5.命令實(shí)例

實(shí)例1

顯示文件中從第3行起的內(nèi)容
命令:

more +3 log.log

輸出:

實(shí)例2

從文件中查找第一個(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í)例3

設(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ì)跟著變化。

實(shí)例4

列一個(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條文件信息。


上一篇:head命令下一篇:which命令