linux more命令的使用

來源:互聯網
上載者:User

linux more命令的使用 more命令,功能類似 cat ,cat命令是整個檔案的內容從上到下顯示在螢幕上。 more會以一頁一頁的顯示方便使用者逐頁閱讀,而最基本的指令就是按空白鍵(space)就往下一頁顯示,按 b 鍵就會往回(back)一頁顯示,而且還有搜尋字串的功能 。more命令從前向後讀取檔案,因此在啟動時就載入整個檔案。 1.命令格式: more [-dlfpcsu ] [-num ] [+/ pattern] [+ linenum] [file ... ] 2.命令功能: more命令和cat的功能一樣都是查看檔案裡的內容,但有所不同的是more可以按頁來查看檔案的內容,還支援直接跳轉行等功能。 3.命令參數: +n      從笫n行開始顯示 -n       定義螢幕大小為n行 +/pattern 在每個檔案顯示前搜尋該字串(pattern),然後從該字串前兩行之後開始顯示  -c       從頂部清屏,然後顯示 -d       提示“Press space to continue,’q’ to quit(按空格鍵繼續,按q鍵退出)”,禁用響鈴功能 -l        忽略Ctrl+l(換頁)字元 -p       通過清除視窗而不是滾屏來對檔案進行換頁,與-c選項相似 -s       把連續的多個空行顯示為一行 -u       把檔案內容中的下畫線去掉 4.常用操作命令: Enter    向下n行,需要定義。預設為1行 Ctrl+F   向下滾動一屏 空格鍵  向下滾動一屏 Ctrl+B  返回上一屏 =       輸出當前行的行號 :f     輸出檔案名和當前行的行號 V      調用vi編輯器 !命令   調用Shell,並執行命令 q       退出more 5.命令執行個體: 執行個體1:顯示檔案中從第3行起的內容 命令: more +3 log2012.log 輸出: [root@localhost test]# cat log2012.log 2012-01 2012-02 2012-03 2012-04-day1 2012-04-day2 2012-04-day3 ======[root@localhost test]# more +3 log2012.log 2012-03 2012-04-day1 2012-04-day2 2012-04-day3 ======[root@localhost test]# 執行個體2:從檔案中尋找第一個出現"day3"字串的行,並從該處前兩行開始顯示輸出 命令: more +/day3 log2012.log 輸出: [root@localhost test]# more +/day3 log2012.log ...skipping 2012-04-day1 2012-04-day2 2012-04-day3 2012-05 2012-05-day1 ======[root@localhost test]# 執行個體3:設定每屏顯示行數 命令: more -5 log2012.log 輸出: [root@localhost test]# more -5 log2012.log 2012-01 2012-02 2012-03 2012-04-day1 2012-04-day2 說明: 如下所示,最下面顯示了該屏展示的內容占檔案總行數的比例,按 Ctrl+F 或者 空格鍵 將會顯示下一屏5條內容,百分比也會跟著變化。 執行個體4:列一個目錄下的檔案,由於內容太多,我們應該學會用more來分頁顯示。這得和管道 | 結合起來 命令: ls -l  | more -5 輸出: [root@localhost test]# ls -l  | more -5 總計 36 -rw-r--r-- 1 root root  308 11-01 16:49 log2012.log -rw-r--r-- 1 root root   33 10-28 16:54 log2013.log -rw-r--r-- 1 root root  127 10-28 16:51 log2014.log lrwxrwxrwx 1 root root    7 10-28 15:18 log_link.log -> log.log -rw-r--r-- 1 root root   25 10-28 17:02 log.log -rw-r--r-- 1 root root   37 10-28 17:07 log.txt drwxr-xr-x 6 root root 4096 10-27 01:58 scf drwxrwxrwx 2 root root 4096 10-28 14:47 test3 drwxrwxrwx 2 root root 4096 10-28 14:47 test4 說明: 每頁顯示5個檔案資訊,按 Ctrl+F 或者 空格鍵 將會顯示下5條檔案資訊。
 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.