每日一個linux命令12-less

1. 命令解析

命令用途
與more類似的對輸出進行分頁顯示的命令,但比more的功能更為強大;

命令格式

less [options] file...

命令參數(shù)

-b <緩沖區(qū)大小> 設(shè)置緩沖區(qū)的大小
-e 當文件顯示結(jié)束后,自動離開
-f 強迫打開特殊文件,例如外圍設(shè)備代號、目錄和二進制文件
-g 只標志最后搜索的關(guān)鍵詞
-i 忽略搜索時的大小寫
-m 顯示類似more命令的百分比
-N 顯示每行的行號
-o <文件名> 將less 輸出的內(nèi)容在指定文件中保存起來
-Q 不使用警告音
-s 顯示連續(xù)空行為一行
-S 行過長時間將超出部分舍棄
-x <數(shù)字> 將“tab”鍵顯示為規(guī)定的數(shù)字空格

操作命令

MOVING

e ^E j ^N CR * Forward one line (or N lines).
y ^Y k ^K ^P * Backward one line (or N lines).
f ^F ^V SPACE * Forward one window (or N lines).
b ^B ESC-v * Backward one window (or N lines).
z * Forward one window (and set window to N).
w * Backward one window (and set window to N).
ESC-SPACE * Forward one window, but don't stop at end-of-file.
d ^D * Forward one half-window (and set half-window to N).
u ^U * Backward one half-window (and set half-window to N).
ESC-) RightArrow * Left one half screen width (or N positions).
ESC-( LeftArrow * Right one half screen width (or N positions).
F Forward forever; like "tail -f".
r ^R ^L Repaint screen.
R Repaint screen, discarding buffered input.


SEARCHING

/pattern * Search forward for (N-th) matching line.
?pattern * Search backward for (N-th) matching line.
n * Repeat previous search (for N-th occurrence).
N * Repeat previous search in reverse direction.
ESC-n * Repeat previous search, spanning files.
ESC-N * Repeat previous search, reverse dir. & spanning files.
ESC-u Undo (toggle) search highlighting.
&pattern * Display only matching lines


JUMPING

g < ESC-< * Go to first line in file (or line N).

G > ESC-> * Go to last line in file (or line N).
p % * Go to beginning of file (or N percent into file).
t * Go to the (N-th) next tag.
T * Go to the (N-th) previous tag.
{ ( [ * Find close bracket } ) ].
} ) ] * Find open bracket { ( [.

2. 示例

2.1 分頁查看文件

less f1

2.2 分頁查看ps的輸出

ps -ef| less

2.3 瀏覽多個文件

less f1 f2

2.4 常用命令

前翻一頁按f
后翻一頁按b
前翻一行按e
后翻一行按y
回到首行,按g
回到末行,按G

向前查找字符串cd,輸入/cd,按n查看下一個結(jié)果
向后查找字符串cd,輸入?cd,按n查看下一個結(jié)果

退出,按q

文件內(nèi)容大時,可以設(shè)置標簽,方便反復(fù)查看:
添加標簽,先按m進入標簽?zāi)J剑偬砑訕撕灻Q比如a(標簽名稱只能為一個字符)
進入標簽a的位置,先按'進入選擇標簽?zāi)J?,再輸入a回到a的位置

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

  • **2014真題Directions:Read the following text. Choose the be...
    又是夜半驚坐起閱讀 11,056評論 0 23
  • 清眸流盼, 眼波溫柔, 間或,眉宇微蹙, 時常,笑藏心頭。 似百合,秀而不媚, 若水仙,清而不寒。 何故愛意悄悄起...
    幽幽墨客閱讀 302評論 0 3
  • 有些事,只能一個人做。有些關(guān),只能一個人過。有些路啊,只能一個人走。不要害怕,也別羞恥,孤獨本就是天性啊。醫(yī)院出...
    是刀疤陳啊閱讀 323評論 0 0
  • 10月31日,和糖果妹妹一起參加金寶貝環(huán)球課之美國。
    易查理閱讀 648評論 1 0
  • 金色的光劃開了天際,遠處的田野也被暗淡。 誰會想起昨天的憂愁,一天的美好全在這里。 誰能與我同行?
    閆小六閱讀 208評論 0 0

友情鏈接更多精彩內(nèi)容