1. 程式人生 > >Linux日誌檢視(5)— more 命令

Linux日誌檢視(5)— more 命令

more命令是一個基於vi編輯器文字過濾器,它以全螢幕的方式按頁顯示文字檔案的內容,支援vi中的關鍵字定位操作。more名單中內建了若干快捷鍵,常用的有H(獲得幫助資訊),Enter(向下翻滾一行),空格(向下滾動一屏),Q(退出命令)。more命令從前向後讀取檔案,因此在啟動時就載入整個檔案。

該命令一次顯示一屏文字,滿屏後停下來,並且在螢幕的底部出現一個提示資訊,給出至今己顯示的該檔案的百分比:–More–(XX%)可以用下列不同的方法對提示做出回答:

  1. 按Space鍵:顯示文字的下一屏內容;
  2. 按Enier鍵:只顯示文字的下一行內容;
  3. 按斜線符|:接著輸入一個模式,可以在文字中尋找下一個相匹配的模式;
  4. 按H鍵:顯示幫助屏,該屏上有相關的幫助資訊;
  5. 按B鍵:顯示上一屏內容;
  6. 按Q鍵:退出more命令。
NAME(名稱)
       more - file perusal filter for crt viewing
              檔案過濾器

SYNOPSIS(概要,大綱)
       more [options] file [...]

DESCRIPTION(描述)
       more  is  a filter for paging through text one screenful at a time.  
       This version is especially primitive.  
       Users should realize that less(1
) provides more(1) emulation plus extensive enhancements. more 命令以全螢幕的方式按頁顯示文字檔案的內容。 這個版本特別原始。 使用者應該瞭解 less 命令提供了比 more 命令更多更強大的功能。 OPTIONS(選項) Command-line options are described below. Options are also taken from the environment variable MORE (make sure to precede them with
a dash (``-'')) but command line options will override them. 命令列選項如下所示。 這些選項也可以從環境變數 MORE 中獲得(確保在這些選項前面有“-”) 另外,命令列選項可以覆蓋他們。 -number This option specifies an integer number which is the screen size (in lines). 指定每屏顯示的行數為 number -d more will prompt the user with the message "[Press space to continue, 'q' to quit.]" and will display "[Press 'h' for instructions.]" instead of ringing the bell when an illegal key is pressed. 提示使用者,在畫面下方顯示 [Press space to continue, 'q' to quit.] , 如果使用者按錯鍵,則會顯示 [Press 'h' for instructions.] 而不是 '嗶' 聲 -l more usually treats ^L (form feed) as a special character, and will pause after any line that contains a form feed. The -l option will prevent this behavior. 取消遇見特殊字元 ^L(送紙字元)時會暫停的功能 -f Causes more to count logical, rather than screen lines (i.e., long lines are not folded). 計算行數時,以實際上的行數,而非自動換行過後的行數(有些單行字數太長的會被擴充套件為兩行或兩行以上) -p Do not scroll. Instead, clear the whole screen and then display the text. Notice that this option is switched on automatically if the executable is named page. 不以滾動的方式顯示每一頁,而是先清除螢幕後再顯示內容。 注意,如果可執行檔案被命名為page,那麼這個選項就會自動開啟。 -c Do not scroll. Instead, paint each screen from the top, clearing the remainder of each line as it is displayed. 跟 -p 相似,不同的是先顯示內容再清除其他舊資料 -s Squeeze multiple blank lines into one. 當遇到有連續兩行以上的空白行,就代換為一行的空白行 -u Suppress underlining. 不顯示下劃線(根據環境變數 TERM 指定的 terminal 而有所不同) +/ The +/ option specifies a string that will be searched for before each file is displayed. 在每個文件顯示前搜尋該字串(string),然後從該字串之後開始顯示 +number Start at line number. 從檔案第 number 行開始顯示 COMMANDS(命令) Interactive commands for more are based on vi(1). Some commands may be preceded by a decimal number, called k in the descriptions below. In the following descriptions, ^X means control-X. more 的互動命令是基於 vi 的。 h or ? Help: display a summary of these commands. If you forget all the other commands, remember this one. 顯示所有命令及功能解釋。 SPACE Display next k lines of text. Defaults to current screen size. 顯示檔案接下來的 k 行。預設為當前的螢幕大小。 z Display next k lines of text. Defaults to current screen size. Argument becomes new default. 顯示接下來的 k 行。預設為當前的螢幕大小。使用後引數變成預設的。 RETURN Display next k lines of text. Defaults to 1. Argument becomes new default. 顯示接下來的 k 行。預設為當前的螢幕大小。使用後引數變成預設的。 d or ^D Scroll k lines. Default is current scroll size, initially 11. Argument becomes new default. 向下滾動 k 行,預設為當前的滾動大小,初始值是11。使用後引數變成預設的。 q or Q or INTERRUPT Exit. 退出 s Skip forward k lines of text. Defaults to 1. 跳過 k 行。並向前滾動。預設為 1。 f Skip forward k screenfuls of text. Defaults to 1. 跳過 k 個整屏的文字。預設為 1。 b or ^B Skip backwards k screenfuls of text. Defaults to 1. Only works with files, not pipes. 跳過k個大螢幕的文字。預設為1。只處理檔案,而不是管道。 ´ Go to place where previous search started. 跳轉到之前搜尋開始的地方。 = Display current line number. 顯示當前的行數。 /pattern Search for kth occurrence of regular expression. Defaults to 1. 查詢正則表示式的第k次出現。預設為1。 n Search for kth occurrence of last regular expression. Defaults to 1. 查詢正則表示式的倒數第k次出現。預設為1。 !command or :!command Execute command in a subshell. 在子shell中執行命令。 v Start up an editor at current line. The editor is taken from the environment variable VISUAL if defined, or EDITOR if VISUAL is not defined, or defaults to vi if neither VISUAL nor EDITOR is defined. 在當前行啟動編輯器。 如果定義了環境變數,那麼編輯器就會從環境變數中獲取,如果沒有定義, 那麼編輯器將被定義為vi,如果沒有定義視覺化和編輯器,則預設為vi。 ^L Redraw screen. 螢幕重繪 :n Go to kth next file. Defaults to 1. 向前跳轉到第K個檔案 :P Go to kth previous file. Defaults to 1. 向回跳轉到第K個檔案 :f Display current file name and line number. 顯示當前的檔名稱和行號 . Repeat previous command. 重複上一個命令 ENVIRONMENT(環境) More utilizes the following environment variables, if they exist: 如果存在以下環境變數,More將使用以下環境變數: MORE This variable may be set with favored options to more. 這個變數可以設定more常用的選項。 SHELL Current shell in use (normally set by the shell at login time). 當前使用的shell(通常在登入時由shell設定)。 TERM Specifies terminal type, used by more to get the terminal characteristics necessary to manipulate the screen. 指定終端型別,更多地用於獲取操作螢幕所需的終端特徵。 VISUAL Editor the user is preferring. Used when key command v is pressed. 使用者更喜歡的編輯器。在按下鍵命令v時使用。 EDITOR Editor of choise when VISUAL is not specified. 當VISUAL環境變數沒有被指定時,使用choise編輯器。

1、逐頁顯示 test.log 文件內容,如有連續兩行以上空白行則以一行空白行顯示。

[[email protected] usr]# more -s test.log
1 2018-03-02 12:39:06:698 YZXBB
2 2018-03-03 12:40:16:700 VGLHY
3 2018-03-04 12:41:17:701 XANRN

        4 2018-03-05 12:42:22:701 RXNYJ
5 2018-03-06 12:43:14:701 BBUEM
6 2018-03-07 12:44:14:701 FKYDL
7 2018-03-08 12:45:08:701 KAHMA
8 2018-03-09 12:46:14:702 GZZXG
9 2018-03-10 12:47:16:702 OEVDO
10 2018-03-11 12:48:06:702 ALXQQ
11 2018-03-12 12:49:10:702 HOCSQ
--More--(5%)

2、從第 20 行開始顯示 testfile 之文件內容。

[[email protected] usr]# more +20 test2.log
220 2018-10-07 19:09:36:781 DJAOD
221 2018-10-08 19:10:31:781 TBYYK
222 2018-10-09 19:11:30:781 LYYPT
223 2018-10-10 19:12:37:781 AXVWT
224 2018-10-11 19:13:33:781 UXSGR
225 2018-10-12 19:14:34:781 TBMJP
226 2018-10-13 19:15:33:781 IMNNK
227 2018-10-14 19:16:23:781 LHEGY
228 2018-10-15 19:17:37:782 YMZPO
--More--(14%)

3、從檔案中查詢第一個出現”ZCJ”字串的行,並從該處前兩行開始顯示輸出

[[email protected] usr]# more +/ZCJ test2.log

...跳過
203 2018-09-20 18:52:37:779 UZDCE
204 2018-09-21 18:53:40:779 NCISH
205 2018-09-22 18:54:34:779 ZCJUY
206 2018-09-23 18:55:38:779 SEJKZ
207 2018-09-24 18:56:27:779 CNGMW
208 2018-09-25 18:57:31:779 GLILU
209 2018-09-26 18:58:24:779 VWUSO
210 2018-09-27 18:59:39:779 HDRAT
211 2018-09-28 19:00:40:779 CFGHE
212 2018-09-29 19:01:41:780 VHLIB
213 2018-09-30 19:02:34:780 NMJPE
214 2018-10-01 19:03:29:780 CJWWI
215 2018-10-02 19:04:40:780 HISAY
--More--(7%)

4、設定每屏顯示行數

[[email protected] usr]# more -5 test2.log
201 2018-09-18 18:50:25:778 ZHWKD
202 2018-09-19 18:51:26:778 VQGRP
203 2018-09-20 18:52:37:779 UZDCE
204 2018-09-21 18:53:40:779 NCISH
205 2018-09-22 18:54:34:779 ZCJUY
--More--(2%)

說明:最下面顯示了該屏展示的內容佔檔案總行數的比例,按 Ctrl+F 或者 空格鍵 將會顯示下一屏5條內容,百分比也會跟著變化。

5、列一個目錄下的檔案,由於內容太多,我們應該學會用more來分頁顯示。這得和管道 | 結合起來 。

[root@peipei3514 usr]# ls -l| more -5
總用量 116
dr-xr-xr-x.  2 root root 20480 1229 15:20 bin
drwxr-xr-x.  2 root root     6 115 2016 etc
drwxr-xr-x.  2 root root     6 115 2016 games
drwxr-xr-x.  3 root root    23 1223 23:12 include
--More--

6、顯示檔案接下來的 5 行

先按數字鍵5,再按空格鍵。

相關推薦

Linux日誌檢視5more 命令

more命令是一個基於vi編輯器文字過濾器,它以全螢幕的方式按頁顯示文字檔案的內容,支援vi中的關鍵字定位操作。more名單中內建了若干快捷鍵,常用的有H(獲得幫助資訊),Enter(向下翻滾一行),空格(向下滾動一屏),Q(退出命令)。more命令從前向後讀取

Linux日誌檢視9— grep 命令詳解+例項

概述 grep(global search regular expression(RE) and print out the line,全面搜尋正則表示式並把行打印出來)是一種強大的文字搜尋工具,它能

Linux日誌檢視8— awk 命令使用例項

基本用法 log.txt 文字內容如下: 2 this is a test 3 Are you like awk This's a test 10 There are orange,apple,mongo 用法一:awk '{[pattern] actio

Linux自學筆記5Linux基礎命令

linux 基礎命令 基礎命令:date:date --help用法:date [選項]... [+格式] 或:date [-u|--utc|--universal] [MMDDhhmm[[CC]YY][-ss]]date [MMDDhhmm[[cc]yy][-ss]]:設置MM:月DD:日hh:時m

Linux鞏固記錄5 hadoop 2.7.4下自己編譯代碼並運行MapReduce程序

parser mod pill self add let tokenize org cto 程序代碼為 ~\hadoop-2.7.4\share\hadoop\mapreduce\sources\hadoop-mapreduce-examples-2.7.4-sourc

Linux學習總結-su命令 sudo 命令 限制root遠程登錄

su - rest 一次 com 註冊 情況 保存配置文件 所有權 是把 root 用戶擁有至高無上的權利,那麽我們運維人員是不是直接在root用戶下處理所有問題呢?答案是否定的,權力越大,責任越大,人是會犯錯的,因此我們要在不影響我們的工作情況下,盡量限制我們的權力,以免

linux audit審計5--audit規則配置

類型 https 不存在 avi mit linux. 文件監控 usr RM audit可以配置規則,這個規則主要是給內核模塊下發的,內核audit模塊會按照這個規則獲取審計信息,發送給auditd來記錄日誌。 規則類型可分為: 1、控制規則:控制audit系統的

Linux日誌管理

日誌一、日誌中的四個WWhen:事件何時發生Where:日誌在哪裏產生Who:哪些程序觸發了這條日誌What:發生了什麽事件 二、一個簡單的日誌收集拓撲網絡設備、服務器通過syslog的協議將日誌傳送到日誌服務器上,日誌服務器定時地將日誌歸檔,儲存到後端存儲設備上。 常用的日誌管理程序為rsyslog和sys

Linux驅動開發5——生成裝置節點

項裝置可以說是對一部分字元裝置的封裝,還有一部分不好歸類驅 動也歸到雜項裝置 雜項裝置初始化部分原始檔“drivers/char/ misc.c”,這一部分通過 Makefile可知,是強制編譯的。 雜項設備註冊標頭檔案include/linux/miscdevice

【領卓教育】Linux學習入門------系統命令之 打補丁

      打補丁,什麼意思,在玩LOL、王者、吃雞...等遊戲的時候,可能大家都遇到過打打補丁的過程,例如版本的升級就是一次打補丁的過程!       首先版本的升級和更新,小編最初以為是把遊戲重新安裝或者覆蓋安裝的過程,可是每次的升

linux學習筆記5:檔案許可權

檔案許可權 1.檔案許可權存在的意義 系統最底層安全設定方法之一 保證檔案可以被可用的使用者做相應操作 2.檔案許可權的檢視 ls -l file ls -ld dir ll file ll -d dir 3.檔案許可權的讀取 - |rw-rw-r--|

Linux學習筆記5磁碟分割槽parted

Linux學習筆記(5)磁碟分割槽(parted) 演示: (1)parted /dev/sdb(可以使用help來檢視命令詳細描述)    (2)p 列出當前磁碟分割槽資訊,可以看出這裡還沒有分割槽,所以下面沒有任何分割槽資訊    (3)mklabel 建立磁碟標籤,選擇gpt格式(這裡會把改

Linux作業系統入門5

系統的日誌管理 rsyslog的管理 /var/log/messages 服務資訊日誌 /var/log/secure 系統登陸日誌 /var/log/cron 定時任務日誌 /var/log/maillog 郵件日誌 /var/log/boot/log 系統啟動日誌

Spark SQL 筆記(15)——實戰網站日誌分析5資料視覺化

1 常見的視覺化框架 echarts highcharts d3.js HUE Zeppelin 2 建立 Web 專案 下載Echarts的檔案放到此目錄 http://echarts.bai

一題多解 —— linux 日誌檔案logreload 重新載入

1. tail -F 等同於–follow=name –retry,根據檔名進行追蹤,並保持重試,即該檔案被刪除或改名後,如果再次建立相同的檔名,會繼續追蹤 也即可以間接實現從日誌檔案末尾,不斷

Linux網路程式設計5:I/O模型

       這一部分的內容本來應該作為第四部分內容,置於上一講之中的。由於當時自己學習時也存在很大的困惑,邊學邊用,因此造成了知識體系的不連貫性。我們開始學習吧。 (1)什麼是I/O複用(I/O multiplexing)呢?         當你編寫的程式需要同時處理多

Linux核心移植5

Linux3.8.3核心移植-根檔案系統製作 根檔案系統,是在linux核心啟動後,第一個掛載的檔案系統。 mkyaffs2image工具製作 mkyaffs2image是製作根檔案系統必要的工具,由yaffs2原始碼編譯生成 1、修改f

每日一vim5c命令change命令

更易理解的版本見vim語 c命令詳解: C or c$ 表示修改當前行上游標後面的部分. 進入編輯狀態. c0 or c^ 表示從游標處到當前行行首的部分進行修改,^代表首個非空格處。 cc OR S 修改當前行. 進入編輯狀態. cw 從游標所在的位置開始到該

DAY-9 Linux基礎及常用命令5

mod conf 自己的路 linux操作 解包 二進制安裝 netstat iptables usr 一、Samba(類似共享網盤) 1、功能:Linux操作系統給win用戶共享文件用 2、如何部署 》》準備環境:iptables –F(清除防火墻)、systemctl

Linux基礎系列:常用命令5_nfs服務與nginx服務

ash .com access emctl 磁盤 keepalive roo inux iptable 介紹:   NFS 是Network File System的縮寫,即網絡文件系統。一種使用於分散式文件系統的協定,由Sun公司開發,於1984年向外公布。功能是通過