歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
您现在的位置: Linux教程網 >> UnixLinux >  >> Linux基礎 >> Linux技術

每天一個Linux命令(12)more命令

more命令是一個基於vi編輯器文本過濾器,它以全屏幕的方式按頁顯示文本文件的內容,支持vi中的關鍵字定位操作。 該命令一次顯示一屏文本,滿屏後停下來,並且在屏幕的底部出現一個提示信息,給出至今己顯示的該文件的百分比:

--More--(XX%)可以用下列不同的方法對提示做出回答: 按Space鍵: 顯示文本的下一屏內容。

按Enier鍵: 只顯示文本的下一行內容。 按斜線符|:接著輸入一個模式,可以在文本中尋找下一個相匹配的模式。 按H鍵: 顯示幫助屏,該屏上有相關的幫助信息。

按B鍵: 顯示上一屏內容。 按Q鍵: 退出more命令。

Ctrl+Z: 退出命令[b] (1)用法:[/b]

用法: more [-dlfpcsu ] [-num ] [+/ pattern] [+ linenum] [file ... ] more [選項] [文件]

[b] (2)功能:[/b] 功能:查看文件文檔中的內容(支持按頁查看和直接跳轉行)

[b] (3)選項參數:[/b] 1) -<數字>: 指定每屏顯示的行數[-num]

2) -d: 顯示“[press space to continue,'q' to quit.]”和“[Press 'h' for instructions]” 3) -c: 不進行滾屏操作。每次刷新這個屏幕

4) -s: 將多個空行壓縮成一行顯示 5) -u: 禁止下劃線

6) +<數字>: 從指定數字的行開始顯示[+linenum] 7) +/pattern: 在每個檔案顯示前搜尋該字串(pattern),然後從該字串前兩行之後開始顯示

[b] (4)實例:[/b] 1)[sunjimeng@localhost Documents]$ more -dc more_text1 顯示文件more_text1的內容,但在顯示之前先清屏,並且在屏幕的最下方顯示完核的百分比。

[sunjimeng@localhost ~]$ cd Documents
[sunjimeng@localhost Documents]$ ll
總用量 4
-rw-r--r--. 1 root root 664 5月   8 19:36 more_text1
[sunjimeng@localhost Documents]$ more -dc more_text1
執行過以後,屏幕只剩下:

I am studing orders of Linux!
I am trying to write as many as lines of text!

No matter how low you consider yourself,
there is always someone looking behind you,
hoping that they were that high!

Something you want keep all the time,always you will lose!

Never forget to say "thanks"!

Hppay today,also,prepared for happiness in the future!

Don't aim your success if you want it,just do what you love and believe and fina
lly you will success!

Maybe you can be laze man like a pig,but you can't feel free as it!

I am a college school student!
I am planning to live and work in hangzhou or guangzhou!
I am from hefei anhui!
Enough,I have write too many words!
[sunjimeng@localhost Documents]$
上面的是終端窗口比較大的情況,所有內容能完全顯示,下面是顯示不完全的情況:

I am studing orders of Linux!
I am trying to write as many as lines of text!

No matter how low you consider yourself,
there is always someone looking behind you,
hoping that they were that high!

Something you want keep all the time,always you will lose!

Never forget to say "thanks"!

Hppay today,also,prepared for happiness in the future!
--More--(51%)[Press space to continue, 'q' to quit.]                  //在這裡顯示百分比
2)[sunjimeng@localhost Documents]$ more -10 more_text1 顯示文件more_text1的內容,每10行顯示一次,而且在顯示之前先清屏。

[sunjimeng@localhost Documents]$ more -10 more_text1
I am studing orders of Linux!
I am trying to write as many as lines of text!

No matter how low you consider yourself,
there is always someone looking behind you,
hoping that they were that high!

Something you want keep all the time,always you will lose!
3)[sunjimeng@localhost Documents]$ more +4 -10 more_text1 從第4行開始顯示,每頁顯示10行

[sunjimeng@localhost Documents]$ more -d -10 more_text1
I am studing orders of Linux!
I am trying to write as many as lines of text!

No matter how low you consider yourself,
there is always someone looking behind you,
hoping that they were that high!

Something you want keep all the time,always you will lose!

--More--(38%)[Press space to continue, 'q' to quit.]                                    //在這裡我按了h鍵,彈出命令的參考。
Most commands optionally preceded by integer argument k.  Defaults in brackets.
Star (*) indicates argument becomes new default.
-------------------------------------------------------------------------------
<space>                 Display next k lines of text [current screen size]
z                       Display next k lines of text [current screen size]*
<return>                Display next k lines of text [1]*
d or ctrl-D             Scroll k lines [current scroll size, initially 11]*
q or Q or <interrupt>   Exit from more
s                       Skip forward k lines of text [1]
f                       Skip forward k screenfuls of text [1]
b or ctrl-B             Skip backwards k screenfuls of text [1]
'                       Go to place where previous search started
=                       Display current line number
/<regular expression>   Search for kth occurrence of regular expression [1]
n                       Search for kth occurrence of last r.e [1]
!<cmd> or :!<cmd>       Execute <cmd> in a subshell
v                       Start up /usr/bin/vi at current line
ctrl-L                  Redraw screen
:n                      Go to kth next file [1]
:p                      Go to kth previous file [1]
:f                      Display current file name and line number
.                       Repeat previous command
-------------------------------------------------------------------------------
和上面的對比可知,此時顯示的也是10行,但第一行的內容和上面第一行的不一樣

[sunjimeng@localhost Documents]$ more +4 -10 more_text1

No matter how low you consider yourself,
there is always someone looking behind you,
hoping that they were that high!

Something you want keep all the time,always you will lose!

Never forget to say "thanks"!

Hppay today,also,prepared for happiness in the future!
--More--(51%)        //上面的百分比是38%
4)[sunjimeng@localhost Documents]$ more +/Never more_text1 找到Never字符串所在的行,然後從此行顯示,之前的跳過

[sunjimeng@localhost Documents]$ more more_text1                          //先查看文檔中的所有文本數據
I am studing orders of Linux!
I am trying to write as many as lines of text!

No matter how low you consider yourself,
there is always someone looking behind you,
hoping that they were that high!

Something you want keep all the time,always you will lose!

Never forget to say "thanks"!

Hppay today,also,prepared for happiness in the future!

Don't aim your success if you want it,just do what you love and believe and finally you will success!

Maybe you can be laze man like a pig,but you can't feel free as it!

I am a college school student!
I am planning to live and work in hangzhou or guangzhou!
I am from hefei anhui!
Enough,I have write too many words!                                       //命令詳解從這裡開始
[sunjimeng@localhost Documents]$ more +/Never more_text1

...跳過
Something you want keep all the time,always you will lose!

Never forget to say "thanks"!

Hppay today,also,prepared for happiness in the future!

Don't aim your success if you want it,just do what you love and believe and finally you will success!

Maybe you can be laze man like a pig,but you can't feel free as it!

I am a college school student!
I am planning to live and work in hangzhou or guangzhou!
I am from hefei anhui!
Enough,I have write too many words!
5)[sunjimeng@localhost Documents]$ cat -n more_text1 |more -10 more命令通常和管道|結合起來使用,配合cat命令帶有特定格式輸出

[sunjimeng@localhost Documents]$ cat -n more_text1 |more -10
     1    I am studing orders of Linux!
     2    I am trying to write as many as lines of text!
     3    
     4    
     5    No matter how low you consider yourself,
     6    there is always someone looking behind you,
     7    hoping that they were that high!
     8    
     9    Something you want keep all the time,always you will lose!
    10    
--More--
6)[sunjimeng@localhost Documents]$ ls -l / | more -5 列一個目錄下的文件,由於內容太多,我們應該學會用more來分頁顯示。這得和管道 | 結合起來。

[sunjimeng@localhost Documents]$ ls -l / | more -5
總用量 32
lrwxrwxrwx.   1 root root    7 5月   1 08:38 bin -> usr/bin
dr-xr-xr-x.   4 root root 4096 5月   1 18:22 boot
drwxr-xr-x.  19 root root 3180 5月   4 07:17 dev
drwxr-xr-x. 137 root root 8192 5月   4 15:16 etc
--more--
說明: 每頁顯示5個文件信息,按 Ctrl+F 或者 空格鍵 將會顯示下5條文件信息。

[b] (5)其他:[/b]  常用操作命令

     Enter    向下n行,需要定義。默認為1行    Ctrl+F    向下滾動一屏

    空格鍵    向下滾動一屏    Ctrl+B    返回上一屏

    =    輸出當前行的行號    f     輸出文件名和當前行的行號

    V    調用vi編輯器    !命令    調用Shell,並執行命令

    q    退出more

Copyright © Linux教程網 All Rights Reserved