lessのヘルプ・マニュアル
日本語 英語
less --help
SSUUMMMMAARRYY OOFF LLEESSSS CCOOMMMMAANNDDSS
Commands marked with * may be preceded by a number, _N.
Notes in parentheses indicate the behavior if _N is given.
h H Display this help.
q :q Q :Q ZZ Exit.
---------------------------------------------------------------------------
MMOOVVIINNGG
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.
---------------------------------------------------
Default "window" is the screen height.
Default "half-window" is half of the screen height.
---------------------------------------------------------------------------
SSEEAARRCCHHIINNGG
/_p_a_t_t_e_r_n * Search forward for (_N-th) matching line.
?_p_a_t_t_e_r_n * 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.
&_p_a_t_t_e_r_n * Display only matching lines
---------------------------------------------------
Search patterns may be modified by one or more of:
^N or ! Search for NON-matching lines.
^E or * Search multiple files (pass thru END OF FILE).
^F or @ Start search at FIRST file (for /) or last file (for ?).
^K Highlight matches, but don't move (KEEP position).
^R Don't use REGULAR EXPRESSIONS.
---------------------------------------------------------------------------
JJUUMMPPIINNGG
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 { ( [.
ESC-^F _<_c_1_> _<_c_2_> * Find close bracket _<_c_2_>.
ESC-^B _<_c_1_> _<_c_2_> * Find open bracket _<_c_1_>
---------------------------------------------------
Each "find close bracket" command goes forward to the close bracket
matching the (_N-th) open bracket in the top line.
Each "find open bracket" command goes backward to the open bracket
matching the (_N-th) close bracket in the bottom line.
m_<_l_e_t_t_e_r_> Mark the current position with .
'_<_l_e_t_t_e_r_> Go to a previously marked position.
'' Go to the previous position.
^X^X Same as '.
---------------------------------------------------
A mark is any upper-case or lower-case letter.
Certain marks are predefined:
^ means beginning of the file
$ means end of the file
---------------------------------------------------------------------------
CCHHAANNGGIINNGG FFIILLEESS
:e [_f_i_l_e] Examine a new file.
^X^V Same as :e.
:n * Examine the (_N-th) next file from the command line.
:p * Examine the (_N-th) previous file from the command line.
:x * Examine the first (or _N-th) file from the command line.
:d Delete the current file from the command line list.
= ^G :f Print current file name.
---------------------------------------------------------------------------
MMIISSCCEELLLLAANNEEOOUUSS CCOOMMMMAANNDDSS
-_<_f_l_a_g_> Toggle a command line option [see OPTIONS below].
--_<_n_a_m_e_> Toggle a command line option, by name.
__<_f_l_a_g_> Display the setting of a command line option.
___<_n_a_m_e_> Display the setting of an option, by name.
+_c_m_d Execute the less cmd each time a new file is examined.
!_c_o_m_m_a_n_d Execute the shell command with $SHELL.
|XX_c_o_m_m_a_n_d Pipe file between current pos & mark XX to shell command.
v Edit the current file with $VISUAL or $EDITOR.
V Print version number of "less".
---------------------------------------------------------------------------
OOPPTTIIOONNSS
Most options may be changed either on the command line,
or from within less by using the - or -- command.
Options may be given in one of two forms: either a single
character preceded by a -, or a name preceeded by --.
-? ........ --help
Display help (from command line).
-a ........ --search-skip-screen
Forward search skips current screen.
-b [_N] .... --buffers=[_N]
Number of buffers.
-B ........ --auto-buffers
Don't automatically allocate buffers for pipes.
-c -C .... --clear-screen --CLEAR-SCREEN
Repaint by clearing rather than scrolling.
-d ........ --dumb
Dumb terminal.
-D [_x_n_._n] . --color=_x_n_._n
Set screen colors. (MS-DOS only)
-e -E .... --quit-at-eof --QUIT-AT-EOF
Quit at end of file.
-f ........ --force
Force open non-regular files.
-F ........ --quit-if-one-screen
Quit if entire file fits on first screen.
-g ........ --hilite-search
Highlight only last match for searches.
-G ........ --HILITE-SEARCH
Don't highlight any matches for searches.
-h [_N] .... --max-back-scroll=[_N]
Backward scroll limit.
-i ........ --ignore-case
Ignore case in searches that do not contain uppercase.
-I ........ --IGNORE-CASE
Ignore case in all searches.
-j [_N] .... --jump-target=[_N]
Screen position of target lines.
-J ........ --status-column
Display a status column at left edge of screen.
-k [_f_i_l_e] . --lesskey-file=[_f_i_l_e]
Use a lesskey file.
-L ........ --no-lessopen
Ignore the LESSOPEN environment variable.
-m -M .... --long-prompt --LONG-PROMPT
Set prompt style.
-n ........ --line-numbers
Don't use line numbers.
-N ........ --LINE-NUMBERS
Use line numbers.
-o [_f_i_l_e] . --log-file=[_f_i_l_e]
Copy to log file (standard input only).
-O [_f_i_l_e] . --LOG-FILE=[_f_i_l_e]
Copy to log file (unconditionally overwrite).
-p [_p_a_t_t_e_r_n] --pattern=[_p_a_t_t_e_r_n]
Start at pattern (from command line).
-P [_p_r_o_m_p_t] --prompt=[_p_r_o_m_p_t]
Define new prompt.
-q -Q .... --quiet --QUIET --silent --SILENT
Quiet the terminal bell.
-r -R .... --raw-control-chars --RAW-CONTROL-CHARS
Output "raw" control characters.
-s ........ --squeeze-blank-lines
Squeeze multiple blank lines.
-S ........ --chop-long-lines
Chop long lines.
-t [_t_a_g] .. --tag=[_t_a_g]
Find a tag.
-T [_t_a_g_s_f_i_l_e] --tag-file=[_t_a_g_s_f_i_l_e]
Use an alternate tags file.
-u -U .... --underline-special --UNDERLINE-SPECIAL
Change handling of backspaces.
-V ........ --version
Display the version number of "less".
-w ........ --hilite-unread
Highlight first new line after forward-screen.
-W ........ --HILITE-UNREAD
Highlight first new line after any forward movement.
-x [_N[,...]] --tabs=[_N[,...]]
Set tab stops.
-X ........ --no-init
Don't use termcap init/deinit strings.
--no-keypad
Don't use termcap keypad init/deinit strings.
-y [_N] .... --max-forw-scroll=[_N]
Forward scroll limit.
-z [_N] .... --window=[_N]
Set size of window.
-" [_c[_c]] . --quotes=[_c[_c]]
Set shell quote characters.
-~ ........ --tilde
Don't display tildes after end of file.
-# [_N] .... --shift=[_N]
Horizontal scroll amount (0 = one half screen width)
---------------------------------------------------------------------------
LLIINNEE EEDDIITTIINNGG
These keys can be used to edit text being entered
on the "command line" at the bottom of the screen.
RightArrow ESC-l Move cursor right one character.
LeftArrow ESC-h Move cursor left one character.
CNTL-RightArrow ESC-RightArrow ESC-w Move cursor right one word.
CNTL-LeftArrow ESC-LeftArrow ESC-b Move cursor left one word.
HOME ESC-0 Move cursor to start of line.
END ESC-$ Move cursor to end of line.
BACKSPACE Delete char to left of cursor.
DELETE ESC-x Delete char under cursor.
CNTL-BACKSPACE ESC-BACKSPACE Delete word to left of cursor.
CNTL-DELETE ESC-DELETE ESC-X Delete word under cursor.
CNTL-U ESC (MS-DOS only) Delete entire line.
UpArrow ESC-k Retrieve previous command line.
DownArrow ESC-j Retrieve next command line.
TAB Complete filename & cycle.
SHIFT-TAB ESC-TAB Complete filename & reverse cycle.
CNTL-L Complete filename, list all.
SSUUMMMMAARRYY OOFF LLEESSSS CCOOMMMMAANNDDSS
Commands marked with * may be preceded by a number, _N.
Notes in parentheses indicate the behavior if _N is given.
h H Display this help.
q :q Q :Q ZZ Exit.
---------------------------------------------------------------------------
MMOOVVIINNGG
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.
---------------------------------------------------
Default "window" is the screen height.
Default "half-window" is half of the screen height.
---------------------------------------------------------------------------
SSEEAARRCCHHIINNGG
/_p_a_t_t_e_r_n * Search forward for (_N-th) matching line.
?_p_a_t_t_e_r_n * 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.
&_p_a_t_t_e_r_n * Display only matching lines
---------------------------------------------------
Search patterns may be modified by one or more of:
^N or ! Search for NON-matching lines.
^E or * Search multiple files (pass thru END OF FILE).
^F or @ Start search at FIRST file (for /) or last file (for ?).
^K Highlight matches, but don't move (KEEP position).
^R Don't use REGULAR EXPRESSIONS.
---------------------------------------------------------------------------
JJUUMMPPIINNGG
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 { ( [.
ESC-^F _<_c_1_> _<_c_2_> * Find close bracket _<_c_2_>.
ESC-^B _<_c_1_> _<_c_2_> * Find open bracket _<_c_1_>
---------------------------------------------------
Each "find close bracket" command goes forward to the close bracket
matching the (_N-th) open bracket in the top line.
Each "find open bracket" command goes backward to the open bracket
matching the (_N-th) close bracket in the bottom line.
m_<_l_e_t_t_e_r_> Mark the current position with .
'_<_l_e_t_t_e_r_> Go to a previously marked position.
'' Go to the previous position.
^X^X Same as '.
---------------------------------------------------
A mark is any upper-case or lower-case letter.
Certain marks are predefined:
^ means beginning of the file
$ means end of the file
---------------------------------------------------------------------------
CCHHAANNGGIINNGG FFIILLEESS
:e [_f_i_l_e] Examine a new file.
^X^V Same as :e.
:n * Examine the (_N-th) next file from the command line.
:p * Examine the (_N-th) previous file from the command line.
:x * Examine the first (or _N-th) file from the command line.
:d Delete the current file from the command line list.
= ^G :f Print current file name.
---------------------------------------------------------------------------
MMIISSCCEELLLLAANNEEOOUUSS CCOOMMMMAANNDDSS
-_<_f_l_a_g_> Toggle a command line option [see OPTIONS below].
--_<_n_a_m_e_> Toggle a command line option, by name.
__<_f_l_a_g_> Display the setting of a command line option.
___<_n_a_m_e_> Display the setting of an option, by name.
+_c_m_d Execute the less cmd each time a new file is examined.
!_c_o_m_m_a_n_d Execute the shell command with $SHELL.
|XX_c_o_m_m_a_n_d Pipe file between current pos & mark XX to shell command.
v Edit the current file with $VISUAL or $EDITOR.
V Print version number of "less".
---------------------------------------------------------------------------
OOPPTTIIOONNSS
Most options may be changed either on the command line,
or from within less by using the - or -- command.
Options may be given in one of two forms: either a single
character preceded by a -, or a name preceeded by --.
-? ........ --help
Display help (from command line).
-a ........ --search-skip-screen
Forward search skips current screen.
-b [_N] .... --buffers=[_N]
Number of buffers.
-B ........ --auto-buffers
Don't automatically allocate buffers for pipes.
-c -C .... --clear-screen --CLEAR-SCREEN
Repaint by clearing rather than scrolling.
-d ........ --dumb
Dumb terminal.
-D [_x_n_._n] . --color=_x_n_._n
Set screen colors. (MS-DOS only)
-e -E .... --quit-at-eof --QUIT-AT-EOF
Quit at end of file.
-f ........ --force
Force open non-regular files.
-F ........ --quit-if-one-screen
Quit if entire file fits on first screen.
-g ........ --hilite-search
Highlight only last match for searches.
-G ........ --HILITE-SEARCH
Don't highlight any matches for searches.
-h [_N] .... --max-back-scroll=[_N]
Backward scroll limit.
-i ........ --ignore-case
Ignore case in searches that do not contain uppercase.
-I ........ --IGNORE-CASE
Ignore case in all searches.
-j [_N] .... --jump-target=[_N]
Screen position of target lines.
-J ........ --status-column
Display a status column at left edge of screen.
-k [_f_i_l_e] . --lesskey-file=[_f_i_l_e]
Use a lesskey file.
-L ........ --no-lessopen
Ignore the LESSOPEN environment variable.
-m -M .... --long-prompt --LONG-PROMPT
Set prompt style.
-n ........ --line-numbers
Don't use line numbers.
-N ........ --LINE-NUMBERS
Use line numbers.
-o [_f_i_l_e] . --log-file=[_f_i_l_e]
Copy to log file (standard input only).
-O [_f_i_l_e] . --LOG-FILE=[_f_i_l_e]
Copy to log file (unconditionally overwrite).
-p [_p_a_t_t_e_r_n] --pattern=[_p_a_t_t_e_r_n]
Start at pattern (from command line).
-P [_p_r_o_m_p_t] --prompt=[_p_r_o_m_p_t]
Define new prompt.
-q -Q .... --quiet --QUIET --silent --SILENT
Quiet the terminal bell.
-r -R .... --raw-control-chars --RAW-CONTROL-CHARS
Output "raw" control characters.
-s ........ --squeeze-blank-lines
Squeeze multiple blank lines.
-S ........ --chop-long-lines
Chop long lines.
-t [_t_a_g] .. --tag=[_t_a_g]
Find a tag.
-T [_t_a_g_s_f_i_l_e] --tag-file=[_t_a_g_s_f_i_l_e]
Use an alternate tags file.
-u -U .... --underline-special --UNDERLINE-SPECIAL
Change handling of backspaces.
-V ........ --version
Display the version number of "less".
-w ........ --hilite-unread
Highlight first new line after forward-screen.
-W ........ --HILITE-UNREAD
Highlight first new line after any forward movement.
-x [_N[,...]] --tabs=[_N[,...]]
Set tab stops.
-X ........ --no-init
Don't use termcap init/deinit strings.
--no-keypad
Don't use termcap keypad init/deinit strings.
-y [_N] .... --max-forw-scroll=[_N]
Forward scroll limit.
-z [_N] .... --window=[_N]
Set size of window.
-" [_c[_c]] . --quotes=[_c[_c]]
Set shell quote characters.
-~ ........ --tilde
Don't display tildes after end of file.
-# [_N] .... --shift=[_N]
Horizontal scroll amount (0 = one half screen width)
---------------------------------------------------------------------------
LLIINNEE EEDDIITTIINNGG
These keys can be used to edit text being entered
on the "command line" at the bottom of the screen.
RightArrow ESC-l Move cursor right one character.
LeftArrow ESC-h Move cursor left one character.
CNTL-RightArrow ESC-RightArrow ESC-w Move cursor right one word.
CNTL-LeftArrow ESC-LeftArrow ESC-b Move cursor left one word.
HOME ESC-0 Move cursor to start of line.
END ESC-$ Move cursor to end of line.
BACKSPACE Delete char to left of cursor.
DELETE ESC-x Delete char under cursor.
CNTL-BACKSPACE ESC-BACKSPACE Delete word to left of cursor.
CNTL-DELETE ESC-DELETE ESC-X Delete word under cursor.
CNTL-U ESC (MS-DOS only) Delete entire line.
UpArrow ESC-k Retrieve previous command line.
DownArrow ESC-j Retrieve next command line.
TAB Complete filename & cycle.
SHIFT-TAB ESC-TAB Complete filename & reverse cycle.
CNTL-L Complete filename, list all.
man less
LESS(1) LESS(1)
名前
less - more の反対 (more のようなページャー)
書式
less -?
less --help
less -V
less --version
less [-[+]aBcCdeEfFgGiIJKLmMnNqQrRsSuUVwWX~]
[-b space] [-h lines] [-j line] [-k keyfile]
[-{oO} logfile] [-p pattern] [-P prompt] [-t tag]
[-T tagsfile] [-x tab,...] [-y lines] [-[z] lines]
[-# shift] [+[+]cmd] [--] [filename]...
(長いオプション名を使う別の書式については、オプションのセクションを参照
すること。)
説明
less は more (1) と同様なプログラムであるが、ファイル内での前方移動と同
様 に後方移動も可能となっている。また、 less は起動時に入力ファイル全体
を読み込む必要がないため、大きな入力ファイルの場合には vi (1) のよう な
テ キ ス トエディタより起動が速い。 less は termcap (システムによっては
terminfo) を使用するため、多くの端末で実行できる。ハードコピー端末で は
、 まだサポートが限定されている (ハードコピー端末では、画面の一番上に表
示されるべき行にキャレット (^) が付く)。
コマンドは more と vi の両方を基本にしている。 (以下の説明において N で
表す) 10 進数の後に続けて使用できるコマンドもある。
コマンド
以 降の説明で ^X は control-X を意味する。 ESC は ESCAPE キーである。例
えば、ESC-v は "ESCAPE" を押した後に "v" を押すという意味である。
h または H
ヘルプ。コマンドの概要を表示する。もし、他のコマンドを忘れた時は
、このコマンドを思い出すこと。
SPACE または ^V または f または ^F
前 方に 1 ウインドウ分 (N 行) 進む (-z オプションを参照)。行数 N
が画面サイズより大きい場合は、最後の行から画面に入りきる分だけを
表 示する。警告: ^V が特殊なリテラル化文字として使われているシス
テムもある。
z SPACE と似ているが、行数 N を指定すると N が新しいウインドウのサ
イズになる。
ESC-SPACE
SPACE と似ているが、ファイルの終端に達した場合でも画面いっぱいに
スクロールする。
RETURN または ^N または e または ^E または j または ^J
前方に 1 行 (N 行) 進む。 N が画面サイズより大きい場合でも、N 行
全てを表示する。
d または ^D
前方に半画面 (N 行) 進む。行数 N を指定すると、その後の d コマン
ドと u コマンドの新しいデフォルトサイズになる。
b または ^B または ESC-v
後方に 1 ウインドウ分 (N 行) 戻る (-z オプションを参照)。 N が画
面サイズより大きい場合は、最後の行から画面に入りきる分だけを表示
する。
w ESC-v と似ているが、N を指定すると、N が新しいウインドウのサイズ
になる。
y または ^Y または ^P または k または ^K
後方に 1 行 (N 行) 戻る。 N が画面サイズより大きい場合でも、N 行
全てを表示する。警告: ^Y が特殊なジョブ制御文字として使われて い
るシステムもある。
u または ^U
後方に半画面 (N 行) 戻る。 N を指定すると、その後の d コマンドと
u コマンドの新しいデフォルトサイズになる。
ESC-) または RIGHTARROW
画面を右方向に画面幅の半分 (N 文字分) スクロールする (-# オプ シ
ョ ン を参照)。テキストがスクロールしている間は、 (行を切り取る)
-S オプションが有効になっているように動作する。文字数 N を入力す
る 場合は、右矢印キーが行編集コマンド (行編集のセクションを参照)
で使われるため、 ESC-) を使用しなければならない。
ESC-( または LEFTARROW
画面を左方向に画面幅の半分 (N 文字分) スクロールする (-# オプ シ
ョンを参照)。
r または ^R または ^L
画面を再描画する。
R 画面を再描画し、バッファされた入力は破棄する。ファイルを閲覧中に
、ファイルが変更された場合に有効である。
F 前方にスクロールし、ファイルの終端に達しても読み続ける。通常この
コマンドは、既にファイルの終端に達している場合に使われる。閲覧中
に大きくなり続けるファイルの末尾をモニターする こ と が で き る
("tail -f" コマンドと同じような動作をする)。
g または < または ESC-<
ファイルの第 1 行目 (第 N 行目) に移動する (警告: N が大きいと遅
くなる)。
G または > または ESC->
ファイルの最終行 (第 N 行目) に移動する (警告: N が大きい場合 や
、N が指定されない場合、また、ファイルではなく標準入力を読み込ん
でいる場合に遅くなる)。
p または %
ファイルの N パーセント目の位置に移動する。 N は 0 から 100 の間
でなければならない。
{ 画面に表示されている先頭行に左中括弧がある場合、 { コマンドを使
うと対応する右中括弧の位置に移動する。対応する右中括弧は画面の最
終 行に表示される。 2 つ以上の左中括弧が画面の先頭行にある場合、
数字 N は第 N 個目の括弧を指定するために使われる。
} 画面に表示されている最終行に右中括弧がある場合、 } コマンドを 使
うと対応する左中括弧の位置に移動する。対応した左中括弧は画面の先
頭行に表示される。 2 つ以上の右中括弧が画面の最終行にある場合 、
数字 N は第 N 個目の括弧を指定するために使われる。
( { コマンドと似ているが、中括弧ではなく小括弧に適用される。
) } コマンドと似ているが、中括弧ではなく小括弧に適用される。
[ { コマンドと似ているが、中括弧ではなく大括弧に適用される。
] } コマンドと似ているが、中括弧ではなく大括弧に適用される。
ESC-^F 2 つの文字を続けて入力することで、{ コマンドと同様の動作をする。
2 つの文字はそれぞれ開括弧と閉括弧として使われる。例え ば 、"ESC
^F < >" を実行すると、画面の先頭行に表示されている < に対応する
> に進むことができる。
ESC-^B 2 つの文字を続けて入力することで、} コマンドと同様の動作をする。
2 つの文字はそれぞれ開括弧と閉括弧として使われる。例えば、"ESC
^B < >" を実行すると、画面の最終行に表示されている > に対応す る
< に戻ることができる。
m 任意の小文字を続けて入力することで、現在の位置を入力した文字でマ
ークする。
’ (シングルクォート)。任意の小文字を続けて入力することで、以前この
文 字でマークした位置に戻る。もう 1 つのシングルクォートを続ける
ことで、シングルクォートコマンドで「大きく」移動する前の位置に戻
る。 ^, $ で、それぞれファイルの先頭行と最終行にジャンプする。新
しいファイルを読み込む場合も前のファイルに付けたマークは保存され
るので、’ コマンドは入力ファイルの切替えに使うことができる。
^X^X シングルクォートと同じ。
/pattern
前 方にあるパターンにマッチする 1 番目 (N 番目) の行を検索する。
このパターンは ed で認識される正規表現である。検索は、画面に表示
されている第 2 行から始まる (変更する場合は、-a と -j オプション
を参照すること)。
パターンの前に置く文字のうち、いくつかは特殊文字となる。これはパ
ターンの一部としてではなく、検索方法を変更するために使われる。
^N または !
パターンにマッチしない行を検索する。
^E または *
複 数のファイルを検索する。つまり、検索がマッチしないまま
現在のファイルの終りに達した場合、コマンドラインのファ イ
ルリストにある次のファイルに検索を続行する。
^F または @
現在の画面表示や、-a または -j オプションの設定に関係なく
、コマンドラインのファイルリストにある最初のファイルの 先
頭行から検索を開始する。
^K 現在の画面中でマッチする全てのパターンをハイライト表示す
る。その際、一番始めにマッチする位置へは移動しない (現 在
の位置を保持する)。
^R 正規表現のためのメタキャラクタを解釈しない。つまり、単純
な文字列比較を行う。
?pattern
後方にあるパターンにマッチする 1 番目 (N 番目) の行を検索する 。
検索は、画面の一番上に表示されている行の前の行から行う。
/ コマンドの時と同様に、一部の文字は特殊な役割をもつ。
^N または !
パターンにマッチしない行を検索する。
^E または *
複 数のファイルを検索する。つまり、検索がマッチしないまま
現在のファイルの先頭に達した場合、コマンドラインのファ イ
ルリストにある前のファイルに検索を続行する。
^F または @
現在の画面表示や、-a または -j オプションの設定に関係なく
、コマンドラインのファイルリストにある最後のファイルの 最
終行から検索を開始する。
^K 前方検索の時と同じ。
^R 前方検索の時と同じ。
ESC-/pattern
"/*"と同じ。
ESC-?pattern
"?*"と同じ。
n 前回の検索を繰り返す。すなわち、前回使用した検索パターンにマッチ
する N 番目の行の検索する。前の検索が ^N で変更されている場合 、
パ ターンにマッチしない N 番目の行を検索する。前の検索が ^E で変
更されている場合、現在のファイルに条件を満たす行がないときは次の
( あるいは前の) ファイルで検索を続ける。前の検索が ^R で変更され
ている場合、正規表現を用いずに検索を行う。前の検索が ^F ま た は
^K で変更されている場合、何の変化も起きない。
N 前回の検索を逆方向に行う。
ESC-n 複数のファイルがあるとき、ファイルを越えて直前の検索を繰り返す。
前の検索が、* によって変更された場合と同じ。
ESC-N 複数のファイルがあるとき、ファイルを越えて逆方向に直前の検索を繰
り返す。
ESC-u 検索結果のハイライトを元の状態に戻す。現在の検索パターンにマッチ
した文字列のハイライトをオフにする。もし既に、前の ESC-u コマ ン
ドによりハイライトがオフになっている場合は、検索コマンドの実行に
よってもハイライトはオンに戻る。 (-G オプションでもハイライト を
オフに切替えることができる。この場合、検索コマンドでハイライトが
オンにならない)。
:e [filename]
新しいファイルを読み込む。ファイル名の指定がない時は、コマンドラ
イ ンのファイルリストから「現在の」ファイル (:n と :p コマンドを
参照) を再度読み込む。ファイル名の中のパーセント記号 (%) は現 在
の フ ァイル名で置き換えられる。ファイル名の中のシャープ記号 (#)
は前に読み込んだファイル名で置き換えられる。しかし、2 つ続けたパ
ー セント記号は、単純に 1 つのパーセント記号に置き換えられる。こ
れは、パーセント記号を含むファイル名を入力できるようにするためで
あ る。同様に、2 つ続けたシャープ記号は、単純に 1 つのシャープ記
号に置き換えられる。このファイル名は、その後に続く :n コマンドと
:p コマンドで閲覧できるように、コマンドラインのファイルリストに
挿入される。複数のファイル名を指定した場合は、全てをファイルのリ
ストに加え、最初のファイルを閲覧する。ファイル名が、1 個以上のス
ペースを含む場合、ファイル名全体がダブルクォートで囲まれていなけ
ればならない ("-" オプションを参照)。
^X^V または E
:e コマンドと同じ。警告: ^V が特殊なリテラル化文字として使われて
いるシステムもある。そのようなシステムでは、^V を使うことはで き
ない。
:n ( コマンドラインで与えられたファイルリストから) 次のファイルを読
み込む。数字 N が指定されている時は、次の N 番目のファイルを読み
込む。
:p コマンドラインのファイルリストにある 1 つ前のファイルを読み込む
。数字 N が指定されている時は、前の N 番目のファイルを読み込む。
:x コマンドラインのファイルリストにある一番最初のファイルを読み込む
。数字 N が指定されている時は、第 N 番目のファイルを読み込む。
:d 現在のファイルをファイルリストから取り除く。
t 現在のタグに 1 つ以上マッチするものがあれば、次のタグへ移動す る
。タグについての詳細は -t オプションを参照。
T 現在のタグに 1 つ以上マッチするものがあれば、前のタグへ移動する
。
= または ^G または :f
閲覧中のファイルについて、ファイル名・表示中の最終行の行番号・バ
イトオフセットといった情報を表示する。可能な場合には、ファイルの
長さ・ファイルの行数・表示されている最終行までのパーセントも表示
する。
- コマンドラインオプション文字 (下記のオプションを参照) のうちの 1
つを続けて入力することで、オプション設定を変更し、新しい設定を解
説するメッセージを表示する。ダッシュのすぐ後に ^P (CONTROL-P) を
入力すると、オプションの設定は変更されるが、メッセージを何も表示
しない。オプション文字が、(-b や -h などの) 数値変数や (-P や -t
などの) 文字列変数の場合、オプション文字の後に新しい値が入力でき
る。値を入力しなかった場合、現在の設定を示すメッセージが表示され
るだけで設定は何も変わらない。
-- - コマンドと似ているが、1 文字のオプションではなく、長いオプショ
ン名 (下記のオプションを参照) が使われる。オプション名を打ち込ん
だ後にリターンを押す必要がある。 2 個目のダッシュのすぐ後 に ^P
を入力すると、- コマンドの場合と同じく、新しい設定を説明するメッ
セージを表示しない。
-+ コマンドラインオプション文字のうちの 1 つを続けて入力すること で
、 オ プ シ ョンをデフォルト設定に戻して、新しい設定を表示する。
("-+X" コマンドは、コマンドラインで "-+X" とするのと同等で あ る
。) このコマンドは文字列の値を持つオプションには使えない。
--+ -+ コマンドと似ているが、1 文字のオプションではなく、長いオプシ
ョン名が使われる。
-! コマンドラインオプション文字のうちの 1 つを続けて入力すること で
、オプションをデフォルト設定の「反対」にして、新しい設定を表示す
る。このコマンドは数字あるいは文字列の値を持つオプションには使え
ない。
--! -! コマンドと似ているが、1 文字のオプションではなく、長いオプシ
ョン名が使われる。
_ (アンダースコア)。コマンドラインオプション文字のうちの 1 つを 続
けて入力することで、そのオプションの現在設定を表示する。オプショ
ンの設定は変化しない。
__ (2 つのアンダースコア)。 _ (アンダースコア) コマンドと似ているが
、 1 文字のオプションではなく、長いオプション名が使われる。オプ
ション名を打ち込んだ後にリターンを押す必要がある。
+cmd 新しいファイルを読み込むたびに、指定したコマンド cmd を毎回実 行
す る。例えば、+G を実行すると less で各ファイルを開いた時に先頭
からではなく終端から表示される。
V 現在起動している less のバージョンを表示する。
q または Q または :q または :Q または ZZ
less を終了する。
以下の 4 つのコマンドが使用できるかは、インストールした方法に依存する。
v 現在閲覧しているファイルを編集するためエディタを起動する。エディ
タとして、環境変数 VISUAL で定義されている値が 用 い ら れ る 。
VISUAL が定義されていない場合、環境変数 EDITOR の値が使われる。
VISUAL も EDITOR も定義されていない場合、"vi" がデフォルトになる
。プロンプトセクションの LESSEDIT に関する話題も参照すること。
! shell-command
指定されたシェルコマンドを実行するため、シェルを起動する。コマン
ド中のパーセント記号 (%) は、現在のファイル名で置き換えられる 。
コ マンド中のシャープ記号 (#) は、前に読み込んだファイル名で置き
換えられる。 "!!" は、直前のシェルコマンドを繰り返す。シェルコマ
ン ドを伴わない "!" は、単にシェルを起動する。 Unix では、シェル
は環境変数 SHELL で設定されたものが使われる。設定されていない 場
合、デフォルトは "sh" である。 MS-DOS と OS/2 では、シェルは通常
のコマンドプロセッサである。
| shell-command
は任意のマーク文字である。入力ファイルのセクションを与えられ
たシェルコマンドに渡す。渡されるファイルのセクションは、現在の画
面の一番上の行から文字でマークされた所までである。ファイルの先頭
行と最終行を示すために、 をそれぞれ ^ と $ にしてもよい。
が . または改行の場合、現在の画面が渡される。
s filename
入力をファイルに保存する。このコマンドは入力が一般のファイルでな
く、パイプの時のみ有効である。
オプション
コ マンドラインオプションを以下に説明する。大部分のオプションは less の
実行中に "-" コマンドを用いて変更することが可能である。
大部分のオプションは、「ダッシュと 1 文字のオプション」または「2 つのダ
ッ シュと長いオプション名」のどちらかの形式で指定される。長いオプション
名は、他のものと区別がつく限り省略できる。例 え ば 、--quit-at-eof は
--quit と省略できるが、 --qui のように省略することはできない。なぜなら
、--quit-at-eof と --quiet が --qui で始まっているからである。大文字 の
オ プ ション名もある。例えば、--QUIT-AT-EOF のようなものがあり、--quit-
at-eof とは区別される。このようなオプション名は、始めの文字を大文字にす
る だ け で よ く、それ以降の文字は大文字でも小文字でも構わない。例えば
、--Quit-at-eof は --QUIT-AT-EOF と等しい。
環境変数 "LESS" の値もオプションとして使われる。例えば、 less を起動 す
るたびに "less -options ..." とタイプするのを避けるために、 csh では、
setenv LESS "-options"
もし、 sh を使っているならば、
LESS="-options"; export LESS
と すればよい。 MS-DOS では、クォーテーションは必要ないが、オプション文
字列中のパーセント記号を 2 つのパーセント記号に置き換える必要がある。
環境変数はコマンドラインより先に解析されているので、コマンドラインオ プ
ションは環境変数 LESS を上書きする。もし、あるオプションが環境変数 LESS
にあっても、コマンドラインオプション "-+" で起動すれば、そのオプショ ン
をデフォルトの値にリセットすることができる。
-P や -D オプションのように文字列を後に続けるオプションでは、文字列の終
りの印としてダラー記号 ($) を使わなくてはならない。例えば、MS-DOS で 2
つ の -D オプションを設定する場合は、次のように間にダラー記号を入れなく
てはならない。
LESS="-Dn9.1$-Ds4.1"
-? または --help
このオプションは、 less が受け付けるコマンドの概要を表示する (h
コマンドと同じ)。 (使用しているシェルが ? をどのように解釈するか
により、 "-\?" というように ? を " で囲む必要があるかもしれな い
。)
-a または --search-skip-screen
画面に表示されている最終行の次の行から検索を開始する。つまり、現
在画面に表示されている行中の検索は行わない。デフォルトでは、検索
は 画面中の第 2 行目 (もしくは最後に検索対象が見つかった行のあと
。-j オプションを参照) から行われる。
-bn または --buffers=n
less が各ファイルに対して使うバッファの数を指定する。各バッフ ァ
は 1KB で、各ファイルに対してデフォルトでは 10 個のバッファを使
う (ただし、ファイルがパイプの場合は例外である。-B オプション を
参照)。数字 n で使用するバッファの数を指定する。
-B または --auto-buffers
データがパイプから読み込まれる場合、デフォルトではバッファは必要
に応じて動的確保される。そのため、大容量のデータがパイプから読み
込まれる場合、多くのメモリが確保されてしまう。 -B オプションが指
定されると、-b オプションで指定されたバッファの数を使うため、 パ
イ プに対するバッファの動的確保が行われない。警告: -B オプション
を使った場合、ファイルの最も最近閲覧している部分のみしかメモリに
保持されず、以前のデータが無くなっているため、表示にエラーが起こ
る場合もある。
-c または --clear-screen
全画面の再描画を、先頭行から下に向かって行わせるようにする。デフ
ォルトでは、全画面の再描画は、画面の最終行からのスクロールによっ
て行われる。
-C または --CLEAR-SCREEN
-C オプションは、-c オプションと似ているが、再描画を行う前に画面
をクリアする。
-d または --dumb
-d オプションは、端末がダムである場合に通常表示されるエラーメッ
セージの表示させない。ダムとは、画面のクリア、後方へのスクロール
といった重要な機能がないことをいう。もしそれらの機能がある場合は
、-d オプションでもダム端末上での less の動作は変更されない。
-Dxcolor または --color=xcolor
[MS-DOS のみ] 表示されるテキストの色を設定する。 x は設定する テ
キ ストのタイプを表す文字である。 n は標準、s は標準出力、d は太
字、u は下線、k は点滅である。 color は、ピリオドで区切られた 数
値 の組である。 1 つ目の数値で文字の前景色、2 つ目の数値で文字の
背景色を選ぶ。数値 N は、N.0 と同じである。
-e または --quit-at-eof
ファイルの終りに 2 度目に達した場合、自動的に less を終了させ る
。デフォルトでは、 less を終了させる唯一の方法は、"q" コマンドで
ある。
-E または --QUIT-AT-EOF
ファイルの終りに 1 度目に達した場合、自動的に less を終了させ る
。
-f または --force
通常のファイルでないものを強制的に開かせる (通常のファイルでない
ものとは、ディレクトリまたはデバイススペシャルファイルのことであ
る) 。また、バイナリファイルを開く場合の警告メッセージも表示しな
い。デフォルトでは、 less は、通常のファイルでないものを開かない
。
-F または --quit-if-one-screen
最初の画面でファイル全体が表示できる場合、 less を自動的に終了さ
せる。
-g または --hilite-search
通常、 less は、前回の検索とマッチする画面中全ての文字列をハイラ
イト表示する。 -g オプションは、前回の検索にマッチした文字列のみ
をハイライト表示するように変更する。このオプションは、 less の動
作をデフォルトより多少速くする。
-G または --HILITE-SEARCH
-G オプションは、検索コマンドで見つかった文字列をハイライト表示
させない。
-hn または ---max-back-scroll=n
後方に戻る最大行数を指定する。もし、n 行を上回って後方に戻る必要
がある場合は、代わりに画面が前方に再描画される (端末が後方に戻る
機能を持たない場合は、-h0 を意味する)。
-i または --ignore-case
大文字小文字の区別をせず、大文字と小文字は同一とみなして検索をす
る。このオプションは、検索パターンに大文字が含まれていた場合には
無視される。つまり、検索パターンに大文字が含まれていた場合、大文
字小文字の区別をした検索をする。
-I または --IGNORE-CASE
-i コマンドと似ているが、検索パターンが大文字を含んでいた場合で
も、検索は大文字小文字の違いを無視して検索をする。
-jn または --jump-target=n
「ターゲット」行とする画面上の行番号を指定する。ターゲット行とは
、テキスト検索、タグ検索、行番号へのジャンプ、ファイルのパーセン
テージでのジャンプ、マーク位置へのジャンプ、の対象となる行である
。 画面の行は数字 n で指定する。画面の一番上の行を 1、その次の行
を 2、...、と表す。画面の最終行から何行目かを指定する場合は、 数
値を負に指定する。画面の一番下の行は -1、下から 2 行目は -2、...
、と指定する。 -j オプションが用いられている時、検索はターゲット
行の直後の行から始まる。例えば、"-j4" のとき、ターゲット行は画面
の第 4 行目なので、検索は画面の第 5 行目から始まる。
-J または --status-column
ステータス欄を画面の左端に表示する。ステータス欄は、-w または -W
オプションが有効なときのみ使われる。
-kfilename または --lesskey-file=filename
lesskey (1) ファイルとして、指定したファイルを less に開かせて処
理させる。複数の -k オプションを指定してもよい。環境変数 LESSKEY
ま たは LESSKEY_SYSTEM が設定された場合、もしくは、 lesskey ファ
イルが標準位置 (「キー割り当て」セクションを参照) に見つかった場
合、それも lesskey ファイルとして使われる。
-K または --quit-on-intr
イ ンタラプト文字 (通常は ^C) を入力した時、すぐさま less を終了
させる。通常インタラプト文字は何をしていようとも less を停止させ
、コマンドプロンプトを返す。
-L または --no-lessopen
環境変数 LESSOPEN を無視する (以下の「入力プリプロセッサ」セクシ
ョンを参照)。このオプションは less の中から設定可能だが、それ 以
降開いたファイルにのみ適用され、現在開いているファイルには適用さ
れない。
-m または --long-prompt
less に、(more のように) 詳細なパーセント表示のプロンプトを出 さ
せる。デフォルトでは、 less は、コロンをプロンプトとして表示する
。
-M または --LONG-PROMPT
more より、さらに詳細なプロンプトを less に出させる。
-n または --line-numbers
行番号を表示させない。 (行番号を表示する) デフォルトの設定では、
特に、入力ファイルが非常に大きな場合に less の動作が遅くなること
がある。 -n オプションで行番号非表示にすることで、この問題を避け
ら れる。行番号の使用とは「プロンプトと = コマンドで行番号が表示
され、 v コマンドで現在の行番号がエディタに渡される」というこ と
である (「プロンプト」セクションにおける LESSEDIT に関する話題を
参照すること)。
-N または --LINE-NUMBERS
画面の各行の先頭に行番号を表示する。
-ofilename または --log-file=filename
less の入力ファイルを指定した名前のファイルにコピーし閲覧する 。
このオプションは、入力ファイルが一般のファイルではなく、パイプで
ある場合にのみ適用される。ファイルが既に存在する時は、上書きする
前に less が確認を求める。
-Ofilename または --LOG-FILE=filename
-O オプションは -o に似ているが、既にあるファイルを確認すること
なく上書きする。
ログファイルが指定されてない場合、 -o と -O オプションは、 less
のなかで、ログファイルを指定するために使うことができる。ファイル
名を指定しない時は、単にログファイル名を表示するだけである。 "s"
コマンドは、 less で、-o を指定するのと同じである。
-ppattern または --pattern=pattern
コ マンドラインでの -p オプションは、 +/pattern を指定するのと同
じである。つまり、ファイル中で pattern が最初に現れると こ ろ を
less の第 1 行目として表示する。
-Pprompt または --prompt=prompt
3 つのプロンプトのスタイルを好みによって調整する方法を提供する。
このオプションは通常、 less コマンドを呼び出すたびに打ち込んだり
せずに、環境変数 LESS で指定する。そのようなオプションは、環境変
数 LESS の中で最後のオプションになっているか、もしくは、ダラー記
号 で終了していなければならない。 -Ps の後に文字列を続けるオプシ
ョンは、デフォルトの (短い) プロンプトをその文字列に変更す る 。
-Pm は中間の (-m) プロンプトを変更する。 -PM は長い (-l) プロン
プトを変更する。 -Ph はヘルプ画面のプロンプトを変更する。 -P= は
= コマンドで表示されるメッセージを変更する。全てのプロンプトの文
字列は、文字列と特別なエスケープシーケンスから構成される。詳細は
「プロンプト」セクションを参照すること。
-q または --quiet または --silent
比較的「静かな」操作にする。スクロールでファイルの終りを過ぎよう
とした場合や、ファイルの始まりより前に行こうとした場合でも、端末
でベルを鳴らさない。端末に「ビジュアルベル」がある場合は、代わり
にそれを使う。不正な文字を打った場合のような、その他のエラーに関
してはベルを鳴らす。デフォルトでは、全てのエラーに関して端末のベ
ルが鳴る。
-Q または --QUIET または --SILENT
完全に「静かな」操作にする。端末のベルは全く鳴らない。
-r または --raw-control-chars
「そのままの」制御文字を表示させるようにする。デフォルトでは、制
御 文字をキャレット表記を使って表示する。例えば、control-A (8 進
数 001) は "^A" と表示される。警告: -r オプションが指定される と
、 less は (制御文字のタイプにどのように画面が反応するかに依存し
ているために) 画面の実際の状況の経過を追うことができない。よって
多くの場合、長い行が誤った位置で分割されてしまうといった問題が生
じる。
-R または --RAW-CONTROL-CHARS
-r と似ているが、可能な場合には画面表示を正しく維持しようとす る
。このオプションが有効なのは、入力が通常のテキストの場合である。
入力には ANSI の「カラー」エスケープシーケンスが含まれていてもよ
い。このシーケンスは
ESC [ ... m
のような形式で、"..." は "m" 以外の 0 個以上の文字である。画面の
状況を保つため、全ての制御文字と ANSI カラーシーケンスはカーソル
を 移動させないと仮定している。 less に "m" 以外の文字を ANSI カ
ラーエスケープシーケンスの終了文字として認識させることもできる。
そ の た め には、認識させたい終了文字のリストを環境変数 LESSAN-
SIENDCHARS に設定すればよい。
-s または --squeeze-blank-lines
連続した空白行を、1 行の空白行にまとめる。 nroff の出力を閲覧 す
るときに役立つ。
-S または --chop-long-lines
画面幅より長い行を折り返さずに切ってしまう。つまり、長い行の残り
の部分を単純に捨ててしまう。デフォルトでは長い行を折り返すので、
残りが次の行に表示される。
-ttag または --tag=tag
-t オプションの後にはタグ名が続き、そのタグを含むファイルを編集
する。このオプションを使うためには、 ctags (1) コマンドであら か
じめ作られた "tags" と呼ばれるファイルが現在のディレクトリになけ
ればならない。このオプションは、新しいファイルを読み込む場 合 に
less のなかで (- コマンドを用いて) 指定することもできる。コマン
ド ":t" は、 less 中で、-t を指定するのと同じである。
-Ttagsfile または --tag-file=tagsfile
"tags" の代わりに使用するタグファイル名を指定する。
-u または --underline-special
バックスペースとキャリッジリターンを印刷可能文字として扱う。つま
り、これらが入力に現れた場合は端末に送られる。
-U または --UNDERLINE-SPECIAL
バックスペース、タブ、キャリッジリターンを制御文字として扱う。つ
まり、これらの文字は -r オプションで指定されたものとして扱う。
デフォルトで -u と -U のどちらも指定されていない場合、下線文字の
隣にあるバックスペースは特別な扱われ方をする。下線された文字は、
端末のハードウェア下線機能を使って表示される。さらに、同一 の 2
文字の間にあるバックスペースも特別な扱われ方をする。重ね打ちされ
た文字が端末のハードウェア太字機能を使って表示される。その他の文
字に続くバックスペースは削除される。その他のキャリッジリターンは
-r オプションで指定されたように扱われる。 -u と -U のどちらも 有
効でない場合に、重ね打ち、もしくは、下線された文字が検索される。
-V または --version
less のバージョンナンバーを表示する。
-w または --hilite-unread
前方に 1 ページ進んだ場合、最初の「新しい」行を一時的にハイラ イ
ト表示する。最初の「新しい」行は、前の画面の最下行の次の行である
。 g または p コマンドの対象となった行もハイライトする。ハイライ
トは、移動させる次のコマンドがあったときに消される。ステータス行
だけをハイライトさせる -J オプションが有効でない限り、行全体がハ
イライトされる。
-W または --HILITE-UNREAD
-w と似ているが、前方に 2 行以上移動した場合に最初の新しい行を一
時的にハイライトする。
-XXX または --mark-wrong-char
表示できない誤った文字を表示するために、マーク文字 (〓) が使われ
るようにする。デフォルトでは、そのような表示できない誤った文字は
、バイナリとして表示される。
-xn,... または --tabs=n,...
タブストップを n 文字に設定する。n をひとつだけ指定した場合は 、
n の倍数でタブストップが設定される。コンマで区切られた複数の値を
指定した場合、それらの位置にタブストップは設定され、最後の二つと
同 じ間隔で続く。例えば、 -x9,17 は 9, 17, 25, 33 のような位置で
タブが設定される。 n のデフォルトは 8 である。
-X または --no-init
端末に、termcap 初期化文字列と非初期化文字列を送れないようにする
。これは、画面をクリアするときのように非初期化文字列が不必要な場
合には、望ましいことがある。
--no-keypad
端末に、keypad 初期化文字列と非初期化文字列を送れないようにす る
。これは、テンキーを構成する keypad 文字列が好ましくないやり方で
振る舞う場合には、望ましいことがある。
-yn または --max-forw-scroll=n
前方に進む最大行数を指定する。もし、n 行を上回って前方に進む必要
が あ る場合は、代わりに画面が再描画される。もし必要であれば、-c
と -C オプションは画面の先頭から再描画するために使われる。デフォ
ルトでは、前方移動はスクロールになる。
-[z]n または --window=n
ス クロールするウインドウのデフォルトの大きさを n 行に変更する。
デフォルトは 1 画面分の行数である。 z と w コマンドはウインド ウ
の 大きさを変更するために使われる。 z は、 more との移植性のため
に省略してもよい。 n が負の数の時は、現在の画面サイズより n 行小
さくウインドウサイズを設定することを意味している。例えば、画面サ
イズが 24 行の場合、-z-4 はスクロールするウインドウを 20 行に 設
定することを意味している。さらに、画面サイズが 40 行に変更された
場合には、自動的にスクロールウインドウは 36 行に変更される。
-"cc or --quotes=cc
ファイル名を引用する文字を変更する。このオプションは、スペースと
ダブルクォーテーションマークの両方を含む名前をファイルに付けよう
とする場合に必要となる。 -" の後に 1 文字を置いた場合、引用文 字
が 指定した 1 文字に変更される。このとき、スペースを含むファイル
名はダブルクォーテーションではなく、この 1 文字で囲まれる。ま た
、-" の後に 2 文字を置いた場合、 1 文字目が開クォーテーションで
、2 文字目が閉クォーテーションになる。このとき、スペースを含むフ
ァイル名の前には開クォーテーション文字を付け、ファイル名の後には
閉クォーテーション文字を付ける。引用文字を変更した後でも、このオ
プ ションは -" (ダッシュの後にダブルクォーテーション) であること
に注意すること。
-~ または --tilde
通常、ファイルの終端より後の行は 1 個のチルダ (~) を使って表示さ
れる。このオプションを使うと、ファイルの終り以降の行は空行として
表示される。
-# または --shift
RIGHTARROW と LEFTARROW コマンドで水平方向にスクロールするときの
デ フォルトの移動桁数を指定する。この値を 0 にすると、デフォルト
の値は画面幅の半分になる。
-- コマンドライン引き数 "--" は、オプション引き数の終りの印である。
この後の、いかなる引き数もファイル名として解釈される。このオプシ
ョンは、名前が"-" または "+" で始まるファイルを閲覧する場合に 役
立つ。
+ あるコマンドラインオプションが + で始まる場合、その残りは、 less
の初期化コマンドとして渡される。例えば、+G では、ファイルの先 頭
で は な く 終端を表示して less を起動させる。そして、オプション
+/xyz では、ファイル中で "xyz" が始めて現れる場所から起動させ る
。特殊な場合として、+ は +g と同じ働きをする。つ
まり、このオプションでは指定された行数から表示が始まる (しかし、
上の "g" コマンドの注意書きを参照すること)。オプションが ++ で始
まっている場合、初期化コマンドは閲覧している一番始めのファイルだ
け でなく、全てのファイルに対して適用される。以前説明した "+" コ
マンドも、全てのファイルに対する初期化コマンドの設定 (およ び 変
更) に使われる。
ラインエディット
画面の一番下で (例えば、:e コマンドのファイル名や、検索コマンドのパター
ンといった) コマンドライン入力の場合、いくつかキーがコマンドラインを 編
集するのに使われる。大部分のコマンドには、[ 大括弧 ] 中の別形式がある。
これは、ある種のキーボードでキーが存在しない場合に使用できる (大括弧 の
中の形式は、MS-DOS 版では機能しない)。それらの特殊キーは、^V や ^A とい
った「リテラル化」文字を先に入力することで、そのままの文字として入力 す
ることができる。 2 つのバックスラッシュを入力することで、バックスラッシ
ュ自身も文字として入力することができる。
LEFTARROW [ ESC-h ]
カーソルを 1 文字分左へ移動する。
RIGHTARROW [ ESC-l ]
カーソルを 1 文字分右へ移動する。
^LEFTARROW [ ESC-b または ESC-LEFTARROW ]
(CONTROL と LEFTARROW を同時に入力すると) カーソルを 1 単語分 左
へ移動する。
^RIGHTARROW [ ESC-w または ESC-RIGHTARROW ]
(CONTROL と RIGHTARROW を同時に入力すると) カーソルを 1 単語分右
へ移動する。
HOME [ ESC-0 ]
カーソルを行頭へ移動する。
END [ ESC-$ ]
カーソルを行末へ移動する。
BACKSPACE
カーソルの左にある文字を消去する。コマンドラインが空の場合は、コ
マンドをキャンセルする。
DELETE または [ ESC-x ]
カーソルの下にある文字を消去する。
^BACKSPACE [ ESC-BACKSPACE ]
(CONTROL と BACKSPACE を同時に入力すると) カーソルの左にある単語
を消去する。
^DELETE [ ESC-X または ESC-DELETE ]
(CONTROL と DELETE を同時に入力すると) カーソルの下にある単語 を
消去する。
UPARROW [ ESC-k ]
(ヒストリにある) 前のコマンドラインを呼び出す。
DOWNARROW [ ESC-j ]
(ヒストリにある) 次のコマンドラインを呼び出す。
TAB カーソルの左にある部分的なファイル名を補完する。複数のマッチする
ファイル名がある時は、最初にマッチしたファイル名がコマンドライン
に 出される。 TAB を繰り返し打つと、マッチしたファイル名が順番に
表示される。補完したファイル名がディレクトリの場合、"/" がファイ
ル名に付加される (MS-DOS では、"\" が付加される)。ディレクトリ名
に付加する文字の指定するために、環境変数 LESSSEPARATOR を使う こ
とができる。
BACKTAB [ ESC-TAB ]
TAB と同様であるが、マッチしたファイル名を逆順に表示する。
^L カーソルの左にある部分的なファイル名を補完する。複数のマッチする
ファイル名がある時は、全てのマッチしたファイル名が入力される。
^U (Unix) または ESC (MS-DOS)
コマンドライン全体を消去する。コマンドが空の場合は、コマンドをキ
ャンセルする。 Unix において、一行消去のための文字を ^U 以外に変
更している場合、その文字が ^U の代わりに使われる。
キー割り当て
lesskey ファイルを生成する lesskey (1) というプログラムを用いて、独自の
less コマンドを定義できる。このファイルは、コマンドキーとそれに関係づけ
られたアクションを指定する。ラインエディットキー (「ラインエディット 」
セクションを参照) の変更や環境変数の設定のために lesskey を使うこともで
きる。環境変数 LESSKEY が設定されている場合、 less は lesskey ファイ ル
名 としてその値を使う。設定されていない場合、 less は、標準の位置にある
lesskey ファイルを探す。 Unix の場合、 less は "$HOME/.less" というファ
イ ル を 探す。 MS-DOS と Windows の場合、 less は "$HOME/_less" という
lesskey ファイルを探す。存在しない場合は、環境変数 PATH で指定されて い
る 全てのディレクトリの下にある "_less" という lesskey ファイルを探す。
OS/2 の場合、 less は "$HOME/less.ini" という lesskey ファイルを探す 。
存 在しない場合は、環境変数 INIT で指定されている全てのディレクトリの下
にある "less.ini" ファイルを探す。それでもない場合は、環境変数 PATH で
指 定されている全てのディレクトリの下にある "less.ini" ファイルを探す。
詳細は lesskey のマニュアルページを参照すること。
キー割り当てを提供するために、システム共通の lesskey ファイルを設定する
こ ともできる。ローカルな lesskey ファイルとシステム共通の lesskey ファ
イルの両方でキーが定義された場合、ローカルなファイルにあるキー割り当 て
の方がシステム共通のキー割り当てより優先される。環境変数 LESSKEY_SYSTEM
が設定されると、 less はそれをシステム共通の lesskey ファイルの名前とし
て 使う。この環境変数が設定されていない場合、 less は次に示す場所を標準
的なシステム共通の lesskey ファイルの場所として探す。 Unix では、システ
ム 共通の lesskey ファイルは /usr/local/bin/.sysless である。 (しかし、
less バイナリ用ディレクトリが /usr/local/bin とは異なる場所にビルドされ
て い た 場 合、そのディレクトリに .sysless ファイルがある。) MS-DOS と
Windows では、システム共通の lesskey ファイルは c:\_sysless で あ る 。
OS/2 では、システム共通の lesskey ファイルは c:\_sysless.ini である。
入力プリプロセッサ
less のための「入力プリプロセッサ」を定義することができる。 less がファ
イルを開く前に、入力プリプロセッサで入力ファイルの内容の表示の仕方を 変
更 することができる。入力プリプロセッサに渡される。入力プリプロセッサは
、ファイルの内容を代替ファイルと呼ばれる別ファイルに書き出す単純な実 行
可 能プログラム (もしくは、シェルスクリプト) である。代替ファイルの内容
がオリジナルファイルの内容の代わりに表示される。しかし、ユーザーにと っ
て はオリジナルファイルが開かれているかのように見える。 less は現在の代
替ファイルの名前としてオリジナルファイルの名前を表示する。
入力プリプロセッサは、ユーザーによって入力されるオリジナルファイル名 を
1 つのコマンドライン引き数として受け付ける。そして、代替ファイルを生成
し終えると、代替ファイル名を標準出力に表示する。入力プリプロセッサが 代
替 ファイル名を出力しない場合、 less は標準としてオリジナルファイルを用
いる。入力プリプロセッサは、標準入力を閲覧する場合には呼び出されない 。
入 力プリプロセッサを設定するためには、入力プリプロセッサを呼び出すコマ
ンドラインを環境変数 LESSOPEN に設定する。このコマンドラインには、入 力
プ リプロセッサコマンドが呼び出されるときに、ファイル名に置き換えられる
文字列 "%s" を含んでいなければならない。
less がそのようにして開いたファイルを閉じる時には、入力ポストプロセッサ
と 呼 ば れ る も う1 つ の プ ログラムが呼び出される。このプログラムは
、(LESSOPEN で開かれた代替ファイルを消去するといった) 全ての必要な後 処
理 をする。このプログラムは、ユーザーによって入力されたオリジナルファイ
ル名と代替ファイル名の 2 つを引き数として受け付ける。入力ポストプロセッ
サ を設定するためには、入力ポストプロセッサを呼び出すコマンドラインを環
境変数 LESSCLOSE に設定する。入力ポストプロセッサコマンドはファイル名に
置き換えられる文字列 "%s" を 2 つ含んでいる。1 つ目はファイルのオリジナ
ルの名前に置き換えられ、2 つ目は LESSOPEN の出力である代替ファイルの 名
前に置き換えられる。
例えば、次の 2 つのスクリプトにより、多くの Unix システムでは、圧縮され
ているファイルを展開せずに less でファイルを閲覧することができる。
lessopen.sh:
#! /bin/sh
case "$1" in
*.Z) uncompress -c $1 >/tmp/less.$$ 2>/dev/null
if [ -s /tmp/less.$$ ]; then
echo /tmp/less.$$
else
rm -f /tmp/less.$$
fi
;;
esac
lessclose.sh:
#! /bin/sh
rm $2
このスクリプトを使うためには、2 つ を 実 行 可 能 な 場 所 に 置 き 、
LESSOPEN="lessopen.sh %s", LESSCLOSE="lessclose.sh %s %s" というように
環境変数を設定する。他の圧縮ファイルを受け付けるような、 更 に 複 雑 な
LESSOPEN と LESSCLOSE スクリプトを書くことも可能である。
フ ァイルのデータを代替ファイルに書き出さず、そのまま、 less にパイプす
るような入力プリプロセッサを設定することも可能である。こうすることに よ
り 、閲覧する前に圧縮ファイル全体を展開するのが避けられる。このような働
きをする入力プリプロセッサは、入力パイプと呼ばれる。入力パイプは、代 替
フ ァイル名を標準出力に表示する代わりに、代替ファイルの内容全てを標準出
力に書き出す。入力パイプが標準出力に何も書き出さない場合、代替ファイ ル
は 生成されず、 less は普通にオリジナルファイルを使う。入力パイプを使う
場合は、入力プリプロセッサが入力パイプであることを知らせるために、環 境
変数 LESSOPEN の最初の文字を、縦棒 (|) に設定する。
例 えば、多くの Unix システムで、次のスクリプトは上で説明したサンプルス
クリプトと同じ働きをする。
lesspipe.sh:
#! /bin/sh
case "$1" in
*.Z) uncompress -c $1 2>/dev/null
;;
esac
このスクリプトを使うためには、実行可能な場所に 置 い て 、 LESSOPEN="|
lesspipe.sh %s" と設定する。入力パイプが使われる場合も、ポストプロセッ
サ LESSCLOSE を使っても良いが、削除する代替ファイルがないので多くの場合
必 要ない。このスクリプトで、LESSCOLSE のポストプロセッサに渡される代替
ファイル名は "-" である。
国際化文字セット
入力ファイルには、3 タイプの文字が含まれている。
ノーマル文字
画面に直接表示できる文字。
制御文字
画面には直接表示すべきでないが、(バックスペースやタブのよ う に)
普通のテキストファイル中にある文字。
バイナリ文字
画面には直接表示すべきでなくテキストファイル中にはない文字。
「 文字セット」とは、簡潔にいうと、どの文字がノーマル文字・制御文字・バ
イナリ文字とされるか、ということである。環境変数 LESSCHARSET が文字セッ
トを選択するのに使われる。この環境変数に設定できる値を以下に示す。
ascii BS, TAB, NL, CR, formfeed が制御文字である。 32 から 126 の値を
持つ文字がノーマルで、その他がバイナリである。
iso8859
ISO 8859 文字セットを選択する。 160 から 255 までの文字がノー マ
ルとして扱われる以外は、ASCII と同じである。
latin1 iso8859 と同じ。
latin9 iso8859 と同じ。
dos MS-DOS 用の文字セットを選択する。
ebcdic EBCDIC 文字セットを選択する。
IBM-1047
OS/390 Unixサービスで使われる EBCDIC 文字セットを選択する。これ
は latin1 の類似物 で あ る 。LESSCHARSET=IBM-1047 あ る い は
LC_CTYPE=en_US のどちらかを設定することにより、似たような結果を
もたらす。
koi8-r ロシア語文字セットを選択する。
next NeXT 計算機用の文字セットを選択する。
utf-8 ISO 10646 文字セットの UTF-8 エンコーディングを選択する。
windows
Microsoft Windowsに適切な文字セットを選択する。(cp1251)
特殊なケースとして、 LESSCHARSET で指定できる限定された文字セットではな
く 、他の文字セットを使うように less を調整したいという場合もある。この
ようなとき、環境変数 LESSCHARDEF が文字セットを定義するのに使われる 。
こ の変数の定義において、文字 "." はノーマルキャラクタ、文字 "c" は制御
文字、文字 "b" はバイナリキャラクタを表す。また、10進数は定義文字の繰り
返 し を示す。例を挙げると、"bccc4b." は値 0 の文字がバイナリ、 1, 2, 3
はコントロール、4, 5, 6 はバイナリ、 8 はノーマルキャラクタという意味で
あ る。最後に文字タイプが指定された文字より後の全ての文字は、最後の文字
と同じタイプとみなされるので、9 から 255 までの値を持つ文字はノーマルと
なる。 (これは 1 つの例であるので、必ずしも実際の文字セットを表している
わけではない。)
下の表は、各 LESSCHARSET と等しい LESSCHARDEF の値を示している。
ascii 8bcccbcc18b95.b
dos 8bcccbcc12bc5b95.b.
ebcdic 5bc6bcc7bcc41b.9b7.9b5.b..8b6.10b6.b9.7b
9.8b8.17b3.3b9.7b9.8b8.6b10.b.b.b.
IBM-1047 4cbcbc3b9cbccbccbb4c6bcc5b3cbbc4bc4bccbc
191.b
iso8859 8bcccbcc18b95.33b.
koi8-r 8bcccbcc18b95.b128.
latin1 8bcccbcc18b95.33b.
next 8bcccbcc18b95.bb125.bb
LESSCHARSET と LESSCHARDEF のどちらも設定されていない場合でも、LC_ALL,
LC_CTYPE あるいは LANG 環境変数に "UTF-8", "UTF8", "utf-8" あ る い は
"utf8" が設定されている場合は、デフォルト文字セットは utf-8 になる。
この文字が見つからない場合、システムが setlocale インターフェースをサポ
ートしていれば、 less は文字セットを決定するのに setlocale を使用する。
setlocale は環境変数 LANG もしくは LC_CTYPE で制御される。
最後に、もし setlocale インターフェースが利用可能でない場合は、デフォル
トの文字セットは latin1 になる。
制御文字とバイナリキャラクタは目立たせて (反転して) 表示される。これ ら
の 文字は、可能であるならば (control-A を ^A というように) キャレット表
記で表示される。キャレット表記は、0100 ビットを反転した結果が印刷可能文
字 になるときのみ使われる。キャレット表記できないときは、角型括弧 <> で
囲まれた 16 進数で表す。このフォーマットは、環境変数 LESSBINFMT を設 定
することで変えられる。 LESSBINFMT は "*"で始まり、もう 1 つの文字が表示
属性を選択する。 "*k" は点滅、"*d" は太字、"*u" は下線、 "*s" は 反 転
、"*n" は標準である。 LESSBINFMT が "*" で始まっていないときは、標準の
属性を仮定する。 LESSBINFMT の残りの部分は、1 つの printf スタイルの エ
ス ケ ー プ シ ー ケ ン ス (% と x, X, o, d など) を含む文字列である。
LESSBINFMT が "*u[%x]" の場合、バイナリキャラクタは大括弧で囲まれた 16
進 数に下線をして表示される。 LESSBINFMT が指定されていないときのデフォ
ルトは、"*s<%02X>" である。注意: LESSBINFMT を経て文字を拡張した結果 は
、31文字より少なくてはならない。
文 字セットが utf-8 の場合、環境変数 LESSUTFBINFMT は LESSBINFMT と同様
に振る舞うが、正常に複合され、表示するのに不適当な Unicode コードポイン
トのみに適用される (例えば、未割り当てのコードポイント)。デフォルト値は
"" である。 LESSUTFBINFMT や LESSBINFMT は表示属性設定 ("*x")
を 共有することに注意。つまり何かを指定すると双方に適用される; LESSUTF-
BINFMT は LESSBINFMT の後に読み込まれ、設定される。もしあれば、優先度を
持つことになる。 UTF-8 ファイル内の問題のあるオクテット (不完全なシーケ
ンスのオクテット、完全ではあるが、non-shortest formシーケンスのオクテッ
ト、不正なオクテット、そしてstray trailing オクテット) が LESSBINFMT 使
い個別に表示される。これは UTF-8 ファイルが不適切に構成されているかの診
断を容易にする。
プロンプト
-P オプションにより、プロンプトを自分の好みに調整することができる。 -P
オプションに与えられた文字列は、指定したプロンプト文字列を置き換える 。
文 字列中のある文字は特殊文字として解釈される。プロンプト機構は柔軟性を
持たせるために少々複雑になっているが、一般のユーザーは、個人用プロン プ
ト文字列の作り方を詳細に理解する必要はない。
パーセント記号は、その後に何の文字が続くかによって展開される。
%bX 現在の入力ファイルへのバイトオフセットで置き換えられる。 b の後
には、(X で示される) 1 文字が続き、どの行のバイトオフセットを 使
うかを指定する。"t" のときは、画面の先頭行のバイトオフセットが使
われる。 "m" は真中の行、"b" は最終行、 "B" は最終行のすぐ次の行
の バ イトオフセットを使うことを意味する。そして、"j" の場合には
-j オプションで指定したターゲット行のバイトオフセットを使うこ と
を意味している。
%B 現在の入力ファイルの大きさに置き換えられる。
%c 画面左端に現れるテキストのカラム番号に置き換えられる。
%dX 対象となる行が入力ファイルにおいて何ページ目であるかに置き換えら
れる。 %b オプションと同じように、X で対象とする行を決定する。
%D 入力ファイルのページ数に置き換えられる。つまり、入力ファイルの最
終行のページ番号に等しい。
%E エディタの名前 (環境変数 VISUAL、VISUAL が定義されていないときは
環境変数 EDITOR) に置き換えられる。以降の、LESSEDIT の特徴に関す
る話題を参照。
%f 現在の入力ファイル名に置き換えられる。
%i 入力ファイルのリスト中における現在のファイルのインデックスで置き
換えられる。
%lX 入力ファイルで何行目にいるかで置き換えられる。対象となる行は、%b
オプションと同じく X で決定される。
%L 入力ファイルの最終行の行番号で置き換えられる。
%m 入力ファイルの合計数で置き換えられる。
%pX バイトオフセットで計算して、現在の入力ファイルで何パーセントの場
所にいるかで置き換えられる。対象となる行は、%b オプションと同 じ
く X で決定される。
%PX 行番号で計算して、現在の入力ファイルで何パーセントの場所にいるか
で置き換えられる。対象となる行は、%b オプションと同じく X で決定
される。
%s %B と同じ。
%t 後に続くスペースを取り除かせる。通常は文字列の後に使われるが、ど
こに置いてもよい。
%x ファイルリストのうちの次の入力ファイル名で置き換えられる。
もし、(入力がパイプのためファイルサイズが分からない場合など) 項目が不明
のときは、代わりにクエスチョンマークが表示される。
プ ロンプト文字列のフォーマットは、ある条件に応じて変更することができる
。クエスチョンマークとその後に続く 1 文字で、"IF" のように働き、どの よ
う な文字が続くかで、条件文が評価される。条件文が真ならば、クエスチョン
マークと条件文字の後に続く文字列からピリオドまでがプロンプトの中に表 示
さ れる。条件文が偽なら、文字列はプロンプトに表示されない。クエスチョン
マークとピリオドの間にあるコロンは、"ELSE" として働き、コロンとピリオド
の間にある文字列は、IF 文が偽のときのみプロンプト文字列に組み入れられる
。 (クエスチョンマークの後の) 条件文字は次のようなものがある。
?a プロンプトに既に文字列が含まれているときに真。
?bX 指定した行のバイトオフセットが既知の場合に真。
?B 現在の入力ファイルの大きさが既知の場合に真。
?c 水平方向にテキストがシフトしている (%c が 0 でない) 場合に真。
?dX 指定された行のページ番号が既知の場合に真。
?e ファイルの終りのときに真。
?f 入力ファイル名があるとき (入力がパイプでないとき) に真。
?lX 指定した行の行番号が既知の場合に真。
?L ファイルの最終行の行番号が既知の場合に真
?m 2 つ以上の入力ファイルがある場合に真。
?n 新しい入力ファイルの最初のプロンプトのとき真。
?pX 指定した行の現在の入力ファイルでのバイトオフセットで計算したパー
セントが既知のとき真。
?PX 指定した行の現在の入力ファイルでの行番号で計算したパーセントが既
知のとき真。
?s "?B" と同じ。
?x 次の入力ファイルがあるとき (現在の入力ファイルが最後のファイルで
ないとき) 真。
特 殊文字 (クエスチョンマーク、コロン、ピリオド、パーセント、バックスラ
ッシュ) 以外の全ての文字がプロンプトの実際に表示される部分になる。特 殊
文 字をプロンプトに表示させるには、その文字の前にバックスラッシュを置け
ばよい。
プロンプトの例をいくつか挙げる。
?f%f:Standard input.
このプロンプトは、ファイル名が既知であれば表示する。わからない と き は
"Standard input" と表示する。
?f%f .?ltLine %lt:?pt%pt\%:?btByte %bt:-...
こ のプロンプトは、ファイル名が既知であれば、ファイル名を表示する。行番
号が既知のときには、ファイル名に続けて行番号を表示する。もし行番号が 既
知 でなく、パーセントが既知のときは、パーセントを表示する。パーセントも
既知でなく、バイトオフセットが既知のときは、バイトオフセットを表示す る
。 バイトオフセットも既知でないときは、ダッシュを表示する。各クエスチョ
ンマークにピリオドがどのように対応しているかに注意すること。ま た 、%pt
の後の % を実際に表示させるために、バックスラッシュでエスケープしている
ことにも注意すること。
?n?f%f .?m(file %i of %m) ..?e(END) ?x- Next\: %x..%t
このプロンプトがファイルにおける最初のプロンプトのときファイル名を表 示
する。さらに、2 つ以上のファイルがあるときは、 "file N of N" というメッ
セージを加える。そして、ファイルの終りに達したときは、文字列 "(END)" を
表 示し、引き続いて次のファイルがあるときはそのファイル名を表示する。最
後に、後に続くスペースを切り詰める。これはデフォルトで使われているプ ロ
ン プトである。参考として、(-m と -M オプションに対応する) 2 つのデフォ
ルトプロンプトを挙げる。ここで 2 行に分けたのは、読みやすさの為だけで実
際は分けない。
?n?f%f .?m(file %i of %m) ..?e(END) ?x- Next\: %x.:
?pB%pB\%:byte %bB?s/%s...%t
?f%f .?n?m(file %i of %m) ..?ltlines %lt-%lb?L/%L. :
byte %bB?s/%s. .?e(END) ?x- Next\: %x.:?pB%pB\%..%t
そ して、次に挙げるのは、= コマンドで出されるデフォルトのメッセージであ
る。
?f%f .?m(file %i of %m) .?ltlines %lt-%lb?L/%L. .
byte %bB?s/%s. ?e(END) :?pB%pB\%..%t
プロンプト展開の機能は、他の目的でも使われる。環境変数 LESSEDIT が定 義
されている場合、この変数は v コマンドで実行されるコマンドとして使われる
。 LESSEDIT の文字列は、プロンプト文字列と同じ方法 で 展 開 さ れ る 。
LESSEDIT のデフォルトの値を以下に示す。
%E ?lm+%lm. %f
こ の文字列は、「エディタ名」・「+ と行数」・「ファイル名」に展開される
。指定したエディタが、"+行数" という書式を受け付けない場合や、呼び出 し
の書式が違う場合は、このデフォルトの LESSEDIT を修正することができる。
セキュリティ
環境変数 LESSSECURE が 1 に設定されている場合、 less は「安全な」モード
で実行される。この場合、次のことができない。
! シェルコマンド
| パイプコマンド
:e ファイルの読み込みコマンド
v 編集コマンド
s -o ログファイル
-k lesskey ファイルを使う
-t タグファイルを使う
ファイル名の中の、* といった、メタキャラクタ
ファイル名補完 (TAB, ^L)
less をいつも「安全な」モードでしか実行できないようにコンパイルすること
も可能である。
環境変数
環境変数は、通常と同じくシステム環境で設定でき、 lesskey (1) ファイルで
も指定できる。環境変数が複数で指定されている場合、ローカルな lesskey フ
ァ イルで定義されている変数は、システム環境で定義されている変数より優先
される。また、システム環境で定義されている変数は、 シ ス テ ム 共 通 の
lesskey ファイルで定義されている変数より優先される。
COLUMNS
画 面の 1 行あたりの文字数を設定する。環境変数 TERM で設定された
値より優先される (TIOCGWINSZ や WIOCGETD をサポートするウイン ド
ウシステムの場合、ウインドウシステムが持つ画面サイズの方が、環境
変数 LINES と COLUMNS より優先される)。
EDITOR (v コマンドで使われる) エディタの名前。
HOME (Unix で lesskey ファイルを探すのに使われる) ユーザーのホーム デ
ィレクトリ名。
HOMEDRIVE, HOMEPATH
環 境 変 数 HOME が設定されていない場合、環境変数 HOMEDRIVE と
HOMEPATH を足したものがユーザーのホームディレクト リ 名 と な る
(Windows バージョンのみで有効)。
INIT (OS/2 で lesskey ファイルを探すのに使われる) ユーザーの init デ
ィレクトリ名。
LANG 文字セットを決定するための言語。
LC_CTYPE
文字セットを決定するための言語。
LESS less に自動的に渡されるオプション。
LESSANSIENDCHARS
ANSI カラーシーケンスの終りとして使われる文字 (デフォルトは "m")
。
LESSBINFMT
印字可能文字でもなく、制御文字でもない文字を表示する際のフォーマ
ット。
LESSCHARDEF
文字セットを定義する。
LESSCHARSET
あらかじめ定義された文字セットを選択する。
LESSCLOSE
(オプションの) 入力ポストプロセッサを呼び出すためのコマンドラ イ
ン。
LESSECHO
lessecho プログラムの名前 (デフォルトは、"lessecho")。 lessecho
プログラムは、Unix システム上のファイル名を、* や ? といったメタ
キャラクタで展開するのに必要である。
LESSEDIT
(v コマンドで使われる) エディタのプロトタイプ文字列。「プロンプ
ト」セクションでの話題を参照。
LESSGLOBALTAGS
グローバルタグを探すための -t オプションで使われるコマンドの名前
。 global (1) コ マ ンドがインストールされている場合は、通常
"global" が設定されるべき。設定されていない場合、グローバルタ グ
は使われない。
LESSKEY
デフォルトの lesskey(1) ファイルの名前。
LESSKEY_SYSTEM
デフォルトで使われるシステム共通の lesskey(1) ファイルの名前。
LESSMETACHARS
シェルに「メタキャラクタ」として解釈される文字のリスト。
LESSMETAESCAPE
less がシェルにコマンドを送る際にメタキャラクタの前に付加するプ
レフィックス。 LESSMETAESCAPE が空の文字列であるとき、メタキャラ
クタを含むコマンドはシェルに送られない。
LESSOPEN
( オプションの) 入力プリプロセッサを起動するためのコマンドライン
。
LESSSECURE
less を「安全な」モードで実行させる。「セキュリティ」セクショ ン
での話題を参照すること。
LESSSEPARATOR
ファイル名補完においてディレクトリ名に付加される文字列。
LINES 画面の行数を設定する。環境変数 TERM で指定された行数より優先され
る。 (TIOCGWINSZ や WIOCGETD をサポートするウインドウシステム の
場 合 、ウインドウシステムが持つ画面サイズの方が、環境変数 LINES
と COLUMNS より優先される)。
PATH (MS-DOS と OS/2 で lesskey ファイルを探すのに使われる) ユーザ ー
の検索パス。
SHELL ! コマンドを実行したり、ファイル名を補完するのに使われるシェル。
TERM less が実行される端末のタイプ。
VISUAL (v コマンドで使われる) エディタの名前。
関連項目
lesskey(1)
警告
(-P オプションで変更されない限り) = コマンドとプロンプトは、画面の先 頭
行 と最終行の行番号を表示する。しかし、バイト数とパーセントは画面最終行
の次行について表示する。
:e コマンドが 2 つ以上のファイルに対して使われ、ファイルのうちの1つが既
に 閲覧されている場合、新しいファイルが予期しない順番でリストに入れられ
る。
ある種の古い端末 (いわゆる「マジッククッキー」端末) では、検索のとき の
ハ イライトが表示エラーを起こす。そのような端末では、この問題を避けるた
め、検索の際のハイライトがデフォルトで不可に設定されている。
検索の際のハイライト表示が設定されている場合に、検索パターンが ^ で始ま
っ て い ると、マッチした文字列以外の部分までハイライトされることがある
(POSIX 正規表現パッケージを使って less がコンパイルされていれば、この問
題は起こらない)。
setlocale が 0 から 31 の値を持つ ASCII 文字をバイナリキャラクタでなく
制御文字とするシステムもある。そのため、 less がある種のバイナリファ イ
ル をバイナリでない通常のファイルとして扱かってしまう。この問題を解決す
るには、環境変数 LESSCHARSET を "ascii" (もしくは、何か適切な文字 セ ッ
ト) に設定すればよい。
こ の バ ー ジ ョ ン の less に 関 す る 既 知のバグの最新リストは、
http://www.flash.net/~marknu/less を参照すること。
著作権
Copyright (C) 2000 Mark Nudelman
less is part of the GNU project and is free software. You can redis-
tribute it and/or modify it under the terms of either (1) the GNU Gen-
eral Public License as published by the Free Software Foundation; or
(2) the Less License. See the file README in the less distribution for
more details regarding redistribution. You should have received a copy
of the GNU General Public License along with the source for less; see
the file COPYING. If not, write to the Free Software Foundation, 59
Temple Place, Suite 330, Boston, MA 02111-1307, USA. You should also
have received a copy of the Less License; see the file LICENSE.
less is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FIT-
NESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
more details.
著者
Mark Nudelman
バ グの報告やコメントは、上のアドレスか bug-less@gnu.org へ送って下さい
。
パッチ
Copyright (c) 1994-2000 Kazushi (Jam) Marukawa, Japanized routines
only
Comments about this part to: jam@pobox.com
You may distribute under the terms of the Less License.
[参考訳]
Copyright (c) 1994-2000 Kazushi (Jam) Marukawa, 日本語化ルーチンのみ。
この部分に関するコメントは jam@pobox.com へ送って下さい。
このパッチは Less ライセンスの下で配布できる。
Version 358: 08 Jul 2000 LESS(1)
LESS(1) LESS(1)
NAME
less - opposite of more
SYNOPSIS
less -?
less --help
less -V
less --version
less [-[+]aBcCdeEfFgGiIJKLmMnNqQrRsSuUVwWX~]
[-b space] [-h lines] [-j line] [-k keyfile]
[-{oO} logfile] [-p pattern] [-P prompt] [-t tag]
[-T tagsfile] [-x tab,...] [-y lines] [-[z] lines]
[-# shift] [+[+]cmd] [--] [filename]...
(See the OPTIONS section for alternate option syntax with long option
names.)
DESCRIPTION
Less is a program similar to more (1), but which allows backward move-
ment in the file as well as forward movement. Also, less does not have
to read the entire input file before starting, so with large input
files it starts up faster than text editors like vi (1). Less uses
termcap (or terminfo on some systems), so it can run on a variety of
terminals. There is even limited support for hardcopy terminals. (On
a hardcopy terminal, lines which should be printed at the top of the
screen are prefixed with a caret.)
Commands are based on both more and vi. Commands may be preceded by a
decimal number, called N in the descriptions below. The number is used
by some commands, as indicated.
COMMANDS
In the following descriptions, ^X means control-X. ESC stands for the
ESCAPE key; for example ESC-v means the two character sequence
"ESCAPE", then "v".
h or H Help: display a summary of these commands. If you forget all
the other commands, remember this one.
SPACE or ^V or f or ^F
Scroll forward N lines, default one window (see option -z
below). If N is more than the screen size, only the final
screenful is displayed. Warning: some systems use ^V as a spe-
cial literalization character.
z Like SPACE, but if N is specified, it becomes the new window
size.
ESC-SPACE
Like SPACE, but scrolls a full screenful, even if it reaches
end-of-file in the process.
RETURN or ^N or e or ^E or j or ^J
Scroll forward N lines, default 1. The entire N lines are dis-
played, even if N is more than the screen size.
d or ^D
Scroll forward N lines, default one half of the screen size. If
N is specified, it becomes the new default for subsequent d and
u commands.
b or ^B or ESC-v
Scroll backward N lines, default one window (see option -z
below). If N is more than the screen size, only the final
screenful is displayed.
w Like ESC-v, but if N is specified, it becomes the new window
size.
y or ^Y or ^P or k or ^K
Scroll backward N lines, default 1. The entire N lines are dis-
played, even if N is more than the screen size. Warning: some
systems use ^Y as a special job control character.
u or ^U
Scroll backward N lines, default one half of the screen size.
If N is specified, it becomes the new default for subsequent d
and u commands.
ESC-) or RIGHTARROW
Scroll horizontally right N characters, default half the screen
width (see the -# option). If a number N is specified, it
becomes the default for future RIGHTARROW and LEFTARROW com-
mands. While the text is scrolled, it acts as though the -S
option (chop lines) were in effect.
ESC-( or LEFTARROW
Scroll horizontally left N characters, default half the screen
width (see the -# option). If a number N is specified, it
becomes the default for future RIGHTARROW and LEFTARROW com-
mands.
r or ^R or ^L
Repaint the screen.
R Repaint the screen, discarding any buffered input. Useful if
the file is changing while it is being viewed.
F Scroll forward, and keep trying to read when the end of file is
reached. Normally this command would be used when already at
the end of the file. It is a way to monitor the tail of a file
which is growing while it is being viewed. (The behavior is
similar to the "tail -f" command.)
g or < or ESC-<
Go to line N in the file, default 1 (beginning of file). (Warn-
ing: this may be slow if N is large.)
G or > or ESC->
Go to line N in the file, default the end of the file. (Warn-
ing: this may be slow if N is large, or if N is not specified
and standard input, rather than a file, is being read.)
p or % Go to a position N percent into the file. N should be between 0
and 100, and may contain a decimal point.
P Go to the line containing byte offset N in the file.
{ If a left curly bracket appears in the top line displayed on the
screen, the { command will go to the matching right curly
bracket. The matching right curly bracket is positioned on the
bottom line of the screen. If there is more than one left curly
bracket on the top line, a number N may be used to specify the
N-th bracket on the line.
} If a right curly bracket appears in the bottom line displayed on
the screen, the } command will go to the matching left curly
bracket. The matching left curly bracket is positioned on the
top line of the screen. If there is more than one right curly
bracket on the top line, a number N may be used to specify the
N-th bracket on the line.
( Like {, but applies to parentheses rather than curly brackets.
) Like }, but applies to parentheses rather than curly brackets.
[ Like {, but applies to square brackets rather than curly brack-
ets.
] Like }, but applies to square brackets rather than curly brack-
ets.
ESC-^F Followed by two characters, acts like {, but uses the two char-
acters as open and close brackets, respectively. For example,
"ESC ^F < >" could be used to go forward to the > which matches
the < in the top displayed line.
ESC-^B Followed by two characters, acts like }, but uses the two char-
acters as open and close brackets, respectively. For example,
"ESC ^B < >" could be used to go backward to the < which matches
the > in the bottom displayed line.
m Followed by any lowercase letter, marks the current position
with that letter.
’ (Single quote.) Followed by any lowercase letter, returns to
the position which was previously marked with that letter. Fol-
lowed by another single quote, returns to the position at which
the last "large" movement command was executed. Followed by a ^
or $, jumps to the beginning or end of the file respectively.
Marks are preserved when a new file is examined, so the ’ com-
mand can be used to switch between input files.
^X^X Same as single quote.
/pattern
Search forward in the file for the N-th line containing the pat-
tern. N defaults to 1. The pattern is a regular expression, as
recognized by the regular expression library supplied by your
system. The search starts at the second line displayed (but see
the -a and -j options, which change this).
Certain characters are special if entered at the beginning of
the pattern; they modify the type of search rather than become
part of the pattern:
^N or !
Search for lines which do NOT match the pattern.
^E or *
Search multiple files. That is, if the search reaches
the END of the current file without finding a match, the
search continues in the next file in the command line
list.
^F or @
Begin the search at the first line of the FIRST file in
the command line list, regardless of what is currently
displayed on the screen or the settings of the -a or -j
options.
^K Highlight any text which matches the pattern on the cur-
rent screen, but don’t move to the first match (KEEP
current position).
^R Don’t interpret regular expression metacharacters; that
is, do a simple textual comparison.
?pattern
Search backward in the file for the N-th line containing the
pattern. The search starts at the line immediately before the
top line displayed.
Certain characters are special as in the / command:
^N or !
Search for lines which do NOT match the pattern.
^E or *
Search multiple files. That is, if the search reaches
the beginning of the current file without finding a
match, the search continues in the previous file in the
command line list.
^F or @
Begin the search at the last line of the last file in the
command line list, regardless of what is currently dis-
played on the screen or the settings of the -a or -j
options.
^K As in forward searches.
^R As in forward searches.
ESC-/pattern
Same as "/*".
ESC-?pattern
Same as "?*".
n Repeat previous search, for N-th line containing the last pat-
tern. If the previous search was modified by ^N, the search is
made for the N-th line NOT containing the pattern. If the pre-
vious search was modified by ^E, the search continues in the
next (or previous) file if not satisfied in the current file.
If the previous search was modified by ^R, the search is done
without using regular expressions. There is no effect if the
previous search was modified by ^F or ^K.
N Repeat previous search, but in the reverse direction.
ESC-n Repeat previous search, but crossing file boundaries. The
effect is as if the previous search were modified by *.
ESC-N Repeat previous search, but in the reverse direction and cross-
ing file boundaries.
ESC-u Undo search highlighting. Turn off highlighting of strings
matching the current search pattern. If highlighting is already
off because of a previous ESC-u command, turn highlighting back
on. Any search command will also turn highlighting back on.
(Highlighting can also be disabled by toggling the -G option; in
that case search commands do not turn highlighting back on.)
&pattern
Display only lines which match the pattern; lines which do not
match the pattern are not displayed. If pattern is empty (if
you type & immediately followed by ENTER), any filtering is
turned off, and all lines are displayed. While filtering is in
effect, an ampersand is displayed at the beginning of the
prompt, as a reminder that some lines in the file may be hidden.
Certain characters are special as in the / command:
^N or !
Display only lines which do NOT match the pattern.
^R Don’t interpret regular expression metacharacters; that
is, do a simple textual comparison.
:e [filename]
Examine a new file. If the filename is missing, the "current"
file (see the :n and :p commands below) from the list of files
in the command line is re-examined. A percent sign (%) in the
filename is replaced by the name of the current file. A pound
sign (#) is replaced by the name of the previously examined
file. However, two consecutive percent signs are simply
replaced with a single percent sign. This allows you to enter a
filename that contains a percent sign in the name. Similarly,
two consecutive pound signs are replaced with a single pound
sign. The filename is inserted into the command line list of
files so that it can be seen by subsequent :n and :p commands.
If the filename consists of several files, they are all inserted
into the list of files and the first one is examined. If the
filename contains one or more spaces, the entire filename should
be enclosed in double quotes (also see the -" option).
^X^V or E
Same as :e. Warning: some systems use ^V as a special literal-
ization character. On such systems, you may not be able to use
^V.
:n Examine the next file (from the list of files given in the com-
mand line). If a number N is specified, the N-th next file is
examined.
:p Examine the previous file in the command line list. If a number
N is specified, the N-th previous file is examined.
:x Examine the first file in the command line list. If a number N
is specified, the N-th file in the list is examined.
:d Remove the current file from the list of files.
t Go to the next tag, if there were more than one matches for the
current tag. See the -t option for more details about tags.
T Go to the previous tag, if there were more than one matches for
the current tag.
= or ^G or :f
Prints some information about the file being viewed, including
its name and the line number and byte offset of the bottom line
being displayed. If possible, it also prints the length of the
file, the number of lines in the file and the percent of the
file above the last displayed line.
- Followed by one of the command line option letters (see OPTIONS
below), this will change the setting of that option and print a
message describing the new setting. If a ^P (CONTROL-P) is
entered immediately after the dash, the setting of the option is
changed but no message is printed. If the option letter has a
numeric value (such as -b or -h), or a string value (such as -P
or -t), a new value may be entered after the option letter. If
no new value is entered, a message describing the current
setting is printed and nothing is changed.
-- Like the - command, but takes a long option name (see OPTIONS
below) rather than a single option letter. You must press
RETURN after typing the option name. A ^P immediately after the
second dash suppresses printing of a message describing the new
setting, as in the - command.
-+ Followed by one of the command line option letters this will
reset the option to its default setting and print a message
describing the new setting. (The "-+X" command does the same
thing as "-+X" on the command line.) This does not work for
string-valued options.
--+ Like the -+ command, but takes a long option name rather than a
single option letter.
-! Followed by one of the command line option letters, this will
reset the option to the "opposite" of its default setting and
print a message describing the new setting. This does not work
for numeric or string-valued options.
--! Like the -! command, but takes a long option name rather than a
single option letter.
_ (Underscore.) Followed by one of the command line option let-
ters, this will print a message describing the current setting
of that option. The setting of the option is not changed.
__ (Double underscore.) Like the _ (underscore) command, but takes
a long option name rather than a single option letter. You must
press RETURN after typing the option name.
+cmd Causes the specified cmd to be executed each time a new file is
examined. For example, +G causes less to initially display each
file starting at the end rather than the beginning.
V Prints the version number of less being run.
q or Q or :q or :Q or ZZ
Exits less.
The following four commands may or may not be valid, depending on your
particular installation.
v Invokes an editor to edit the current file being viewed. The
editor is taken from the environment variable VISUAL if defined,
or EDITOR if VISUAL is not defined, or defaults to "vi" if nei-
ther VISUAL nor EDITOR is defined. See also the discussion of
LESSEDIT under the section on PROMPTS below.
! shell-command
Invokes a shell to run the shell-command given. A percent sign
(%) in the command is replaced by the name of the current file.
A pound sign (#) is replaced by the name of the previously exam-
ined file. "!!" repeats the last shell command. "!" with no
shell command simply invokes a shell. On Unix systems, the
shell is taken from the environment variable SHELL, or defaults
to "sh". On MS-DOS and OS/2 systems, the shell is the normal
command processor.
| shell-command
represents any mark letter. Pipes a section of the input
file to the given shell command. The section of the file to be
piped is between the first line on the current screen and the
position marked by the letter. may also be ^ or $ to indi-
cate beginning or end of file respectively. If is . or new-
line, the current screen is piped.
s filename
Save the input to a file. This only works if the input is a
pipe, not an ordinary file.
OPTIONS
Command line options are described below. Most options may be changed
while less is running, via the "-" command.
Most options may be given in one of two forms: either a dash followed
by a single letter, or two dashes followed by a long option name. A
long option name may be abbreviated as long as the abbreviation is
unambiguous. For example, --quit-at-eof may be abbreviated --quit, but
not --qui, since both --quit-at-eof and --quiet begin with --qui. Some
long option names are in uppercase, such as --QUIT-AT-EOF, as distinct
from --quit-at-eof. Such option names need only have their first let-
ter capitalized; the remainder of the name may be in either case. For
example, --Quit-at-eof is equivalent to --QUIT-AT-EOF.
Options are also taken from the environment variable "LESS". For exam-
ple, to avoid typing "less -options ..." each time less is invoked, you
might tell csh:
setenv LESS "-options"
or if you use sh:
LESS="-options"; export LESS
On MS-DOS, you don’t need the quotes, but you should replace any per-
cent signs in the options string by double percent signs.
The environment variable is parsed before the command line, so command
line options override the LESS environment variable. If an option
appears in the LESS variable, it can be reset to its default value on
the command line by beginning the command line option with "-+".
For options like -P or -D which take a following string, a dollar sign
($) must be used to signal the end of the string. For example, to set
two -D options on MS-DOS, you must have a dollar sign between them,
like this:
LESS="-Dn9.1$-Ds4.1"
-? or --help
This option displays a summary of the commands accepted by less
(the same as the h command). (Depending on how your shell
interprets the question mark, it may be necessary to quote the
question mark, thus: "-\?".)
-a or --search-skip-screen
Causes searches to start after the last line displayed on the
screen, thus skipping all lines displayed on the screen. By
default, searches start at the second line on the screen (or
after the last found line; see the -j option).
-bn or --buffers=n
Specifies the amount of buffer space less will use for each
file, in units of kilobytes (1024 bytes). By default 64K of
buffer space is used for each file (unless the file is a pipe;
see the -B option). The -b option specifies instead that n
kilobytes of buffer space should be used for each file. If n is
-1, buffer space is unlimited; that is, the entire file can be
read into memory.
-B or --auto-buffers
By default, when data is read from a pipe, buffers are allocated
automatically as needed. If a large amount of data is read from
the pipe, this can cause a large amount of memory to be allo-
cated. The -B option disables this automatic allocation of
buffers for pipes, so that only 64K (or the amount of space
specified by the -b option) is used for the pipe. Warning: use
of -B can result in erroneous display, since only the most
recently viewed part of the piped data is kept in memory; any
earlier data is lost.
-c or --clear-screen
Causes full screen repaints to be painted from the top line
down. By default, full screen repaints are done by scrolling
from the bottom of the screen.
-C or --CLEAR-SCREEN
Same as -c, for compatibility with older versions of less.
-d or --dumb
The -d option suppresses the error message normally displayed if
the terminal is dumb; that is, lacks some important capability,
such as the ability to clear the screen or scroll backward. The
-d option does not otherwise change the behavior of less on a
dumb terminal.
-Dxcolor or --color=xcolor
[MS-DOS only] Sets the color of the text displayed. x is a sin-
gle character which selects the type of text whose color is
being set: n=normal, s=standout, d=bold, u=underlined, k=blink.
color is a pair of numbers separated by a period. The first
number selects the foreground color and the second selects the
background color of the text. A single number N is the same as
N.M, where M is the normal background color.
-e or --quit-at-eof
Causes less to automatically exit the second time it reaches
end-of-file. By default, the only way to exit less is via the
"q" command.
-E or --QUIT-AT-EOF
Causes less to automatically exit the first time it reaches end-
of-file.
-f or --force
Forces non-regular files to be opened. (A non-regular file is a
directory or a device special file.) Also suppresses the warn-
ing message when a binary file is opened. By default, less will
refuse to open non-regular files. Note that some operating sys-
tems will not allow directories to be read, even if -f is set.
-F or --quit-if-one-screen
Causes less to automatically exit if the entire file can be dis-
played on the first screen.
-g or --hilite-search
Normally, less will highlight ALL strings which match the last
search command. The -g option changes this behavior to high-
light only the particular string which was found by the last
search command. This can cause less to run somewhat faster than
the default.
-G or --HILITE-SEARCH
The -G option suppresses all highlighting of strings found by
search commands.
--old-bot
Reverts to the old bottom of screen behavior. This can be some-
times desirable if the long lines are not wrapped correctly
when reaching the bottom of the terminal, while scrolling
forward.
-hn or --max-back-scroll=n
Specifies a maximum number of lines to scroll backward. If it
is necessary to scroll backward more than n lines, the screen is
repainted in a forward direction instead. (If the terminal does
not have the ability to scroll backward, -h0 is implied.)
-i or --ignore-case
Causes searches to ignore case; that is, uppercase and lowercase
are considered identical. This option is ignored if any upper-
case letters appear in the search pattern; in other words, if a
pattern contains uppercase letters, then that search does not
ignore case.
-I or --IGNORE-CASE
Like -i, but searches ignore case even if the pattern contains
uppercase letters.
-jn or --jump-target=n
Specifies a line on the screen where the "target" line is to be
positioned. The target line is the line specified by any com-
mand to search for a pattern, jump to a line number, jump to a
file percentage or jump to a tag. The screen line may be speci-
fied by a number: the top line on the screen is 1, the next is
2, and so on. The number may be negative to specify a line rel-
ative to the bottom of the screen: the bottom line on the screen
is -1, the second to the bottom is -2, and so on. Alternately,
the screen line may be specified as a fraction of the height of
the screen, starting with a decimal point: .5 is in the middle
of the screen, .3 is three tenths down from the first line, and
so on. If the line is specified as a fraction, the actual line
number is recalculated if the terminal window is resized, so
that the target line remains at the specified fraction of the
screen height. If any form of the -j option is used, forward
searches begin at the line immediately after the target line,
and backward searches begin at the target line. For example, if
"-j4" is used, the target line is the fourth line on the screen,
so forward searches begin at the fifth line on the screen.
-J or --status-column
Displays a status column at the left edge of the screen. The
status column shows the lines that matched the current search.
The status column is also used if the -w or -W option is in
effect.
-kfilename or --lesskey-file=filename
Causes less to open and interpret the named file as a lesskey
(1) file. Multiple -k options may be specified. If the LESSKEY
or LESSKEY_SYSTEM environment variable is set, or if a lesskey
file is found in a standard place (see KEY BINDINGS), it is also
used as a lesskey file.
-K or --quit-on-intr
Causes less to exit immediately when an interrupt character
(usually ^C) is typed. Normally, an interrupt character causes
less to stop whatever it is doing and return to its command
prompt. Note that use of this option makes it impossible to
return to the command prompt from the "F" command.
-L or --no-lessopen
Ignore the LESSOPEN environment variable (see the INPUT PREPRO-
CESSOR section below). This option can be set from within less,
but it will apply only to files opened subsequently, not to the
file which is currently open.
-m or --long-prompt
Causes less to prompt verbosely (like more), with the percent
into the file. By default, less prompts with a colon.
-M or --LONG-PROMPT
Causes less to prompt even more verbosely than more.
-n or --line-numbers
Suppresses line numbers. The default (to use line numbers) may
cause less to run more slowly in some cases, especially with a
very large input file. Suppressing line numbers with the -n
option will avoid this problem. Using line numbers means: the
line number will be displayed in the verbose prompt and in the =
command, and the v command will pass the current line number to
the editor (see also the discussion of LESSEDIT in PROMPTS
below).
-N or --LINE-NUMBERS
Causes a line number to be displayed at the beginning of each
line in the display.
-ofilename or --log-file=filename
Causes less to copy its input to the named file as it is being
viewed. This applies only when the input file is a pipe, not an
ordinary file. If the file already exists, less will ask for
confirmation before overwriting it.
-Ofilename or --LOG-FILE=filename
The -O option is like -o, but it will overwrite an existing file
without asking for confirmation.
If no log file has been specified, the -o and -O options can be
used from within less to specify a log file. Without a file
name, they will simply report the name of the log file. The "s"
command is equivalent to specifying -o from within less.
-ppattern or --pattern=pattern
The -p option on the command line is equivalent to specifying
+/pattern; that is, it tells less to start at the first occur-
rence of pattern in the file.
-Pprompt or --prompt=prompt
Provides a way to tailor the three prompt styles to your own
preference. This option would normally be put in the LESS envi-
ronment variable, rather than being typed in with each less com-
mand. Such an option must either be the last option in the LESS
variable, or be terminated by a dollar sign. -Ps followed by a
string changes the default (short) prompt to that string. -Pm
changes the medium (-m) prompt. -PM changes the long (-M)
prompt. -Ph changes the prompt for the help screen. -P=
changes the message printed by the = command. -Pw changes the
message printed while waiting for data (in the F command). All
prompt strings consist of a sequence of letters and special
escape sequences. See the section on PROMPTS for more details.
-q or --quiet or --silent
Causes moderately "quiet" operation: the terminal bell is not
rung if an attempt is made to scroll past the end of the file or
before the beginning of the file. If the terminal has a "visual
bell", it is used instead. The bell will be rung on certain
other errors, such as typing an invalid character. The default
is to ring the terminal bell in all such cases.
-Q or --QUIET or --SILENT
Causes totally "quiet" operation: the terminal bell is never
rung.
-r or --raw-control-chars
Causes "raw" control characters to be displayed. The default is
to display control characters using the caret notation; for
example, a control-A (octal 001) is displayed as "^A". Warning:
when the -r option is used, less cannot keep track of the actual
appearance of the screen (since this depends on how the screen
responds to each type of control character). Thus, various dis-
play problems may result, such as long lines being split in the
wrong place.
-R or --RAW-CONTROL-CHARS
Like -r, but only ANSI "color" escape sequences are output in
"raw" form. Unlike -r, the screen appearance is maintained cor-
rectly in most cases. ANSI "color" escape sequences are
sequences of the form:
ESC [ ... m
where the "..." is zero or more color specification characters
For the purpose of keeping track of screen appearance, ANSI
color escape sequences are assumed to not move the cursor. You
can make less think that characters other than "m" can end ANSI
color escape sequences by setting the environment variable
LESSANSIENDCHARS to the list of characters which can end a color
escape sequence. And you can make less think that characters
other than the standard ones may appear between the ESC and the
m by setting the environment variable LESSANSIMIDCHARS to the
list of characters which can appear.
-s or --squeeze-blank-lines
Causes consecutive blank lines to be squeezed into a single
blank line. This is useful when viewing nroff output.
-S or --chop-long-lines
Causes lines longer than the screen width to be chopped rather
than folded. That is, the portion of a long line that does not
fit in the screen width is not shown. The default is to fold
long lines; that is, display the remainder on the next line.
-ttag or --tag=tag
The -t option, followed immediately by a TAG, will edit the file
containing that tag. For this to work, tag information must be
available; for example, there may be a file in the current
directory called "tags", which was previously built by ctags (1)
or an equivalent command. If the environment variable LESSGLOB-
ALTAGS is set, it is taken to be the name of a command compati-
ble with global (1), and that command is executed to find the
tag. (See http://www.gnu.org/software/global/global.html). The
-t option may also be specified from within less (using the -
command) as a way of examining a new file. The command ":t" is
equivalent to specifying -t from within less.
-Ttagsfile or --tag-file=tagsfile
Specifies a tags file to be used instead of "tags".
-u or --underline-special
Causes backspaces and carriage returns to be treated as print-
able characters; that is, they are sent to the terminal when
they appear in the input.
-U or --UNDERLINE-SPECIAL
Causes backspaces, tabs and carriage returns to be treated as
control characters; that is, they are handled as specified by
the -r option.
By default, if neither -u nor -U is given, backspaces which
appear adjacent to an underscore character are treated spe-
cially: the underlined text is displayed using the terminal’s
hardware underlining capability. Also, backspaces which appear
between two identical characters are treated specially: the
overstruck text is printed using the terminal’s hardware bold-
face capability. Other backspaces are deleted, along with the
preceding character. Carriage returns immediately followed by a
newline are deleted. other carriage returns are handled as
specified by the -r option. Text which is overstruck or under-
lined can be searched for if neither -u nor -U is in effect.
-V or --version
Displays the version number of less.
-w or --hilite-unread
Temporarily highlights the first "new" line after a forward
movement of a full page. The first "new" line is the line imme-
diately following the line previously at the bottom of the
screen. Also highlights the target line after a g or p command.
The highlight is removed at the next command which causes move-
ment. The entire line is highlighted, unless the -J option is
in effect, in which case only the status column is highlighted.
-W or --HILITE-UNREAD
Like -w, but temporarily highlights the first new line after any
forward movement command larger than one line.
-xn,... or --tabs=n,...
Sets tab stops. If only one n is specified, tab stops are set
at multiples of n. If multiple values separated by commas are
specified, tab stops are set at those positions, and then con-
tinue with the same spacing as the last two. For example,
-x9,17 will set tabs at positions 9, 17, 25, 33, etc. The
default for n is 8.
-X or --no-init
Disables sending the termcap initialization and deinitialization
strings to the terminal. This is sometimes desirable if the
deinitialization string does something unnecessary, like clear-
ing the screen.
-yn or --max-forw-scroll=n
Specifies a maximum number of lines to scroll forward. If it is
necessary to scroll forward more than n lines, the screen is
repainted instead. The -c or -C option may be used to repaint
from the top of the screen if desired. By default, any forward
movement causes scrolling.
-[z]n or --window=n
Changes the default scrolling window size to n lines. The
default is one screenful. The z and w commands can also be used
to change the window size. The "z" may be omitted for compati-
bility with some versions of more. If the number n is negative,
it indicates n lines less than the current screen size. For
example, if the screen is 24 lines, -z-4 sets the scrolling win-
dow to 20 lines. If the screen is resized to 40 lines, the
scrolling window automatically changes to 36 lines.
-"cc or --quotes=cc
Changes the filename quoting character. This may be necessary
if you are trying to name a file which contains both spaces and
quote characters. Followed by a single character, this changes
the quote character to that character. Filenames containing a
space should then be surrounded by that character rather than by
double quotes. Followed by two characters, changes the open
quote to the first character, and the close quote to the second
character. Filenames containing a space should then be preceded
by the open quote character and followed by the close quote
character. Note that even after the quote characters are
changed, this option remains -" (a dash followed by a double
quote).
-~ or --tilde
Normally lines after end of file are displayed as a single tilde
(~). This option causes lines after end of file to be displayed
as blank lines.
-# or --shift
Specifies the default number of positions to scroll horizontally
in the RIGHTARROW and LEFTARROW commands. If the number speci-
fied is zero, it sets the default number of positions to one
half of the screen width. Alternately, the number may be speci-
fied as a fraction of the width of the screen, starting with a
decimal point: .5 is half of the screen width, .3 is three
tenths of the screen width, and so on. If the number is speci-
fied as a fraction, the actual number of scroll positions is
recalculated if the terminal window is resized, so that the
actual scroll remains at the specified fraction of the screen
width.
--no-keypad
Disables sending the keypad initialization and deinitialization
strings to the terminal. This is sometimes useful if the keypad
strings make the numeric keypad behave in an undesirable manner.
--follow-name
Normally, if the input file is renamed while an F command is
executing, less will continue to display the contents of the
original file despite its name change. If --follow-name is
specified, during an F command less will periodically attempt to
reopen the file by name. If the reopen succeeds and the file is
a different file from the original (which means that a new file
has been created with the same name as the original (now
renamed) file), less will display the contents of that new file.
-- A command line argument of "--" marks the end of option argu-
ments. Any arguments following this are interpreted as file-
names. This can be useful when viewing a file whose name begins
with a "-" or "+".
+ If a command line option begins with +, the remainder of that
option is taken to be an initial command to less. For example,
+G tells less to start at the end of the file rather than the
beginning, and +/xyz tells it to start at the first occurrence
of "xyz" in the file. As a special case, + acts like
+g; that is, it starts the display at the specified line
number (however, see the caveat under the "g" command above).
If the option starts with ++, the initial command applies to
every file being viewed, not just the first one. The + command
described previously may also be used to set (or change) an ini-
tial command for every file.
LINE EDITING
When entering command line at the bottom of the screen (for example, a
filename for the :e command, or the pattern for a search command), cer-
tain keys can be used to manipulate the command line. Most commands
have an alternate form in [ brackets ] which can be used if a key does
not exist on a particular keyboard. (Note that the forms beginning
with ESC do not work in some MS-DOS and Windows systems because ESC is
the line erase character.) Any of these special keys may be entered
literally by preceding it with the "literal" character, either ^V or
^A. A backslash itself may also be entered literally by entering two
backslashes.
LEFTARROW [ ESC-h ]
Move the cursor one space to the left.
RIGHTARROW [ ESC-l ]
Move the cursor one space to the right.
^LEFTARROW [ ESC-b or ESC-LEFTARROW ]
(That is, CONTROL and LEFTARROW simultaneously.) Move the cur-
sor one word to the left.
^RIGHTARROW [ ESC-w or ESC-RIGHTARROW ]
(That is, CONTROL and RIGHTARROW simultaneously.) Move the cur-
sor one word to the right.
HOME [ ESC-0 ]
Move the cursor to the beginning of the line.
END [ ESC-$ ]
Move the cursor to the end of the line.
BACKSPACE
Delete the character to the left of the cursor, or cancel the
command if the command line is empty.
DELETE or [ ESC-x ]
Delete the character under the cursor.
^BACKSPACE [ ESC-BACKSPACE ]
(That is, CONTROL and BACKSPACE simultaneously.) Delete the
word to the left of the cursor.
^DELETE [ ESC-X or ESC-DELETE ]
(That is, CONTROL and DELETE simultaneously.) Delete the word
under the cursor.
UPARROW [ ESC-k ]
Retrieve the previous command line.
DOWNARROW [ ESC-j ]
Retrieve the next command line.
TAB Complete the partial filename to the left of the cursor. If it
matches more than one filename, the first match is entered into
the command line. Repeated TABs will cycle thru the other
matching filenames. If the completed filename is a directory, a
"/" is appended to the filename. (On MS-DOS systems, a "\" is
appended.) The environment variable LESSSEPARATOR can be used
to specify a different character to append to a directory name.
BACKTAB [ ESC-TAB ]
Like, TAB, but cycles in the reverse direction thru the matching
filenames.
^L Complete the partial filename to the left of the cursor. If it
matches more than one filename, all matches are entered into the
command line (if they fit).
^U (Unix and OS/2) or ESC (MS-DOS)
Delete the entire command line, or cancel the command if the
command line is empty. If you have changed your line-kill char-
acter in Unix to something other than ^U, that character is used
instead of ^U.
KEY BINDINGS
You may define your own less commands by using the program lesskey (1)
to create a lesskey file. This file specifies a set of command keys
and an action associated with each key. You may also use lesskey to
change the line-editing keys (see LINE EDITING), and to set environment
variables. If the environment variable LESSKEY is set, less uses that
as the name of the lesskey file. Otherwise, less looks in a standard
place for the lesskey file: On Unix systems, less looks for a lesskey
file called "$HOME/.less". On MS-DOS and Windows systems, less looks
for a lesskey file called "$HOME/_less", and if it is not found there,
then looks for a lesskey file called "_less" in any directory specified
in the PATH environment variable. On OS/2 systems, less looks for a
lesskey file called "$HOME/less.ini", and if it is not found, then
looks for a lesskey file called "less.ini" in any directory specified
in the INIT environment variable, and if it not found there, then looks
for a lesskey file called "less.ini" in any directory specified in the
PATH environment variable. See the lesskey manual page for more
details.
A system-wide lesskey file may also be set up to provide key bindings.
If a key is defined in both a local lesskey file and in the system-wide
file, key bindings in the local file take precedence over those in the
system-wide file. If the environment variable LESSKEY_SYSTEM is set,
less uses that as the name of the system-wide lesskey file. Otherwise,
less looks in a standard place for the system-wide lesskey file: On
Unix systems, the system-wide lesskey file is /usr/local/etc/sysless.
(However, if less was built with a different sysconf directory than
/usr/local/etc, that directory is where the sysless file is found.) On
MS-DOS and Windows systems, the system-wide lesskey file is c:\_sys-
less. On OS/2 systems, the system-wide lesskey file is c:\sysless.ini.
INPUT PREPROCESSOR
You may define an "input preprocessor" for less. Before less opens a
file, it first gives your input preprocessor a chance to modify the way
the contents of the file are displayed. An input preprocessor is sim-
ply an executable program (or shell script), which writes the contents
of the file to a different file, called the replacement file. The con-
tents of the replacement file are then displayed in place of the con-
tents of the original file. However, it will appear to the user as if
the original file is opened; that is, less will display the original
filename as the name of the current file.
An input preprocessor receives one command line argument, the original
filename, as entered by the user. It should create the replacement
file, and when finished, print the name of the replacement file to its
standard output. If the input preprocessor does not output a replace-
ment filename, less uses the original file, as normal. The input pre-
processor is not called when viewing standard input. To set up an
input preprocessor, set the LESSOPEN environment variable to a command
line which will invoke your input preprocessor. This command line
should include one occurrence of the string "%s", which will be
replaced by the filename when the input preprocessor command is
invoked.
When less closes a file opened in such a way, it will call another pro-
gram, called the input postprocessor, which may perform any desired
clean-up action (such as deleting the replacement file created by
LESSOPEN). This program receives two command line arguments, the orig-
inal filename as entered by the user, and the name of the replacement
file. To set up an input postprocessor, set the LESSCLOSE environment
variable to a command line which will invoke your input postprocessor.
It may include two occurrences of the string "%s"; the first is
replaced with the original name of the file and the second with the
name of the replacement file, which was output by LESSOPEN.
For example, on many Unix systems, these two scripts will allow you to
keep files in compressed format, but still let less view them directly:
lessopen.sh:
#! /bin/sh
case "$1" in
*.Z) uncompress -
if [ -s /tmp/less.$$ ]; then
echo /tmp/less.$$
else
rm -f /tmp/less.$$
fi
;;
esac
lessclose.sh:
#! /bin/sh
rm $2
To use these scripts, put them both where they can be executed and set
LESSOPEN="lessopen.sh %s", and LESSCLOSE="lessclose.sh %s %s". More
complex LESSOPEN and LESSCLOSE scripts may be written to accept other
types of compressed files, and so on.
It is also possible to set up an input preprocessor to pipe the file
data directly to less, rather than putting the data into a replacement
file. This avoids the need to decompress the entire file before start-
ing to view it. An input preprocessor that works this way is called an
input pipe. An input pipe, instead of writing the name of a replace-
ment file on its standard output, writes the entire contents of the
replacement file on its standard output. If the input pipe does not
write any characters on its standard output, then there is no replace-
ment file and less uses the original file, as normal. To use an input
pipe, make the first character in the LESSOPEN environment variable a
vertical bar (|) to signify that the input preprocessor is an input
pipe.
For example, on many Unix systems, this script will work like the pre-
vious example scripts:
lesspipe.sh:
#! /bin/sh
case "$1" in
*.Z) uncompress -c $1 2>/dev/null
;;
esac
To use this script, put it where it can be executed and set
LESSOPEN="|lesspipe.sh %s". When an input pipe is used, a LESSCLOSE
postprocessor can be used, but it is usually not necessary since there
is no replacement file to clean up. In this case, the replacement file
name passed to the LESSCLOSE postprocessor is "-".
For compatibility with previous versions of less, the input preproces-
sor or pipe is not used if less is viewing standard input. However, if
the first character of LESSOPEN is a dash (-), the input preprocessor
is used on standard input as well as other files. In this case, the
dash is not considered to be part of the preprocessor command. If
standard input is being viewed, the input preprocessor is passed a file
name consisting of a single dash. Similarly, if the first two charac-
ters of LESSOPEN are vertical bar and dash (|-), the input pipe is used
on standard input as well as other files. Again, in this case the dash
is not considered to be part of the input pipe command.
NATIONAL CHARACTER SETS
There are three types of characters in the input file:
normal characters
can be displayed directly to the screen.
control characters
should not be displayed directly, but are expected to be found
in ordinary text files (such as backspace and tab).
binary characters
should not be displayed directly and are not expected to be
found in text files.
A "character set" is simply a description of which characters are to be
considered normal, control, and binary. The LESSCHARSET environment
variable may be used to select a character set. Possible values for
LESSCHARSET are:
ascii BS, TAB, NL, CR, and formfeed are control characters, all chars
with values between 32 and 126 are normal, and all others are
binary.
iso8859
Selects an ISO 8859 character set. This is the same as ASCII,
except characters between 160 and 255 are treated as normal
characters.
latin1 Same as iso8859.
latin9 Same as iso8859.
dos Selects a character set appropriate for MS-DOS.
ebcdic Selects an EBCDIC character set.
IBM-1047
Selects an EBCDIC character set used by OS/390 Unix Services.
This is the EBCDIC analogue of latin1. You get similar results
by setting either LESSCHARSET=IBM-1047 or LC_CTYPE=en_US in your
environment.
koi8-r Selects a Russian character set.
next Selects a character set appropriate for NeXT computers.
utf-8 Selects the UTF-8 encoding of the ISO 10646 character set.
UTF-8 is special in that it supports multi-byte characters in
the input file. It is the only character set that supports
multi-byte characters.
windows
Selects a character set appropriate for Microsoft Windows (cp
1251).
In rare cases, it may be desired to tailor less to use a character set
other than the ones definable by LESSCHARSET. In this case, the envi-
ronment variable LESSCHARDEF can be used to define a character set. It
should be set to a string where each character in the string represents
one character in the character set. The character "." is used for a
normal character, "c" for control, and "b" for binary. A decimal num-
ber may be used for repetition. For example, "bccc4b." would mean
character 0 is binary, 1, 2 and 3 are control, 4, 5, 6 and 7 are
binary, and 8 is normal. All characters after the last are taken to be
the same as the last, so characters 9 through 255 would be normal.
(This is an example, and does not necessarily represent any real char-
acter set.)
This table shows the value of LESSCHARDEF which is equivalent to each
of the possible values for LESSCHARSET:
ascii 8bcccbcc18b95.b
dos 8bcccbcc12bc5b95.b.
ebcdic 5bc6bcc7bcc41b.9b7.9b5.b..8b6.10b6.b9.7b
9.8b8.17b3.3b9.7b9.8b8.6b10.b.b.b.
IBM-1047 4cbcbc3b9cbccbccbb4c6bcc5b3cbbc4bc4bccbc
191.b
iso8859 8bcccbcc18b95.33b.
koi8-r 8bcccbcc18b95.b128.
latin1 8bcccbcc18b95.33b.
next 8bcccbcc18b95.bb125.bb
If neither LESSCHARSET nor LESSCHARDEF is set, but any of the strings
"UTF-8", "UTF8", "utf-8" or "utf8" is found in the LC_ALL, LC_TYPE or
LANG environment variables, then the default character set is utf-8.
If that string is not found, but your system supports the setlocale
interface, less will use setlocale to determine the character set.
setlocale is controlled by setting the LANG or LC_CTYPE environment
variables.
Finally, if the setlocale interface is also not available, the default
character set is latin1.
Control and binary characters are displayed in standout (reverse
video). Each such character is displayed in caret notation if possible
(e.g. ^A for control-A). Caret notation is used only if inverting the
0100 bit results in a normal printable character. Otherwise, the char-
acter is displayed as a hex number in angle brackets. This format can
be changed by setting the LESSBINFMT environment variable. LESSBINFMT
may begin with a "*" and one character to select the display attribute:
"*k" is blinking, "*d" is bold, "*u" is underlined, "*s" is standout,
and "*n" is normal. If LESSBINFMT does not begin with a "*", normal
attribute is assumed. The remainder of LESSBINFMT is a string which
may include one printf-style escape sequence (a % followed by x, X, o,
d, etc.). For example, if LESSBINFMT is "*u[%x]", binary characters
are displayed in underlined hexadecimal surrounded by brackets. The
default if no LESSBINFMT is specified is "*s<%02X>". Warning: the
result of expanding the character via LESSBINFMT must be less than 31
characters.
When the character set is utf-8, the LESSUTFBINFMT environment variable
acts similarly to LESSBINFMT but it applies to Unicode code points that
were successfully decoded but are unsuitable for display (e.g., unas-
signed code points). Its default value is "". Note that
LESSUTFBINFMT and LESSBINFMT share their display attribute setting
("*x") so specifying one will affect both; LESSUTFBINFMT is read after
LESSBINFMT so its setting, if any, will have priority. Problematic
octets in a UTF-8 file (octets of a truncated sequence, octets of a
complete but non-shortest form sequence, illegal octets, and stray
trailing octets) are displayed individually using LESSBINFMT so as to
facilitate diagnostic of how the UTF-8 file is ill-formed.
PROMPTS
The -P option allows you to tailor the prompt to your preference. The
string given to the -P option replaces the specified prompt string.
Certain characters in the string are interpreted specially. The prompt
mechanism is rather complicated to provide flexibility, but the ordi-
nary user need not understand the details of constructing personalized
prompt strings.
A percent sign followed by a single character is expanded according to
what the following character is:
%bX Replaced by the byte offset into the current input file. The b
is followed by a single character (shown as X above) which spec-
ifies the line whose byte offset is to be used. If the charac-
ter is a "t", the byte offset of the top line in the display is
used, an "m" means use the middle line, a "b" means use the bot-
tom line, a "B" means use the line just after the bottom line,
and a "j" means use the "target" line, as specified by the -j
option.
%B Replaced by the size of the current input file.
%c Replaced by the column number of the text appearing in the first
column of the screen.
%dX Replaced by the page number of a line in the input file. The
line to be used is determined by the X, as with the %b option.
%D Replaced by the number of pages in the input file, or equiva-
lently, the page number of the last line in the input file.
%E Replaced by the name of the editor (from the VISUAL environment
variable, or the EDITOR environment variable if VISUAL is not
defined). See the discussion of the LESSEDIT feature below.
%f Replaced by the name of the current input file.
%i Replaced by the index of the current file in the list of input
files.
%lX Replaced by the line number of a line in the input file. The
line to be used is determined by the X, as with the %b option.
%L Replaced by the line number of the last line in the input file.
%m Replaced by the total number of input files.
%pX Replaced by the percent into the current input file, based on
byte offsets. The line used is determined by the X as with the
%b option.
%PX Replaced by the percent into the current input file, based on
line numbers. The line used is determined by the X as with the
%b option.
%s Same as %B.
%t Causes any trailing spaces to be removed. Usually used at the
end of the string, but may appear anywhere.
%x Replaced by the name of the next input file in the list.
If any item is unknown (for example, the file size if input is a pipe),
a question mark is printed instead.
The format of the prompt string can be changed depending on certain
conditions. A question mark followed by a single character acts like
an "IF": depending on the following character, a condition is evalu-
ated. If the condition is true, any characters following the question
mark and condition character, up to a period, are included in the
prompt. If the condition is false, such characters are not included.
A colon appearing between the question mark and the period can be used
to establish an "ELSE": any characters between the colon and the period
are included in the string if and only if the IF condition is false.
Condition characters (which follow a question mark) may be:
?a True if any characters have been included in the prompt so far.
?bX True if the byte offset of the specified line is known.
?B True if the size of current input file is known.
?c True if the text is horizontally shifted (%c is not zero).
?dX True if the page number of the specified line is known.
?e True if at end-of-file.
?f True if there is an input filename (that is, if input is not a
pipe).
?lX True if the line number of the specified line is known.
?L True if the line number of the last line in the file is known.
?m True if there is more than one input file.
?n True if this is the first prompt in a new input file.
?pX True if the percent into the current input file, based on byte
offsets, of the specified line is known.
?PX True if the percent into the current input file, based on line
numbers, of the specified line is known.
?s Same as "?B".
?x True if there is a next input file (that is, if the current
input file is not the last one).
Any characters other than the special ones (question mark, colon,
period, percent, and backslash) become literally part of the prompt.
Any of the special characters may be included in the prompt literally
by preceding it with a backslash.
Some examples:
?f%f:Standard input.
This prompt prints the filename, if known; otherwise the string "Stan-
dard input".
?f%f .?ltLine %lt:?pt%pt\%:?btByte %bt:-...
This prompt would print the filename, if known. The filename is fol-
lowed by the line number, if known, otherwise the percent if known,
otherwise the byte offset if known. Otherwise, a dash is printed.
Notice how each question mark has a matching period, and how the %
after the %pt is included literally by escaping it with a backslash.
?n?f%f .?m(file %i of %m) ..?e(END) ?x- Next\: %x..%t
This prints the filename if this is the first prompt in a file, fol-
lowed by the "file N of N" message if there is more than one input
file. Then, if we are at end-of-file, the string "(END)" is printed
followed by the name of the next file, if there is one. Finally, any
trailing spaces are truncated. This is the default prompt. For refer-
ence, here are the defaults for the other two prompts (-m and -M
respectively). Each is broken into two lines here for readability
only.
?n?f%f .?m(file %i of %m) ..?e(END) ?x- Next\: %x.:
?pB%pB\%:byte %bB?s/%s...%t
?f%f .?n?m(file %i of %m) ..?ltlines %lt-%lb?L/%L. :
byte %bB?s/%s. .?e(END) ?x- Next\: %x.:?pB%pB\%..%t
And here is the default message produced by the = command:
?f%f .?m(file %i of %m) .?ltlines %lt-%lb?L/%L. .
byte %bB?s/%s. ?e(END) :?pB%pB\%..%t
The prompt expansion features are also used for another purpose: if an
environment variable LESSEDIT is defined, it is used as the command to
be executed when the v command is invoked. The LESSEDIT string is
expanded in the same way as the prompt strings. The default value for
LESSEDIT is:
%E ?lm+%lm. %f
Note that this expands to the editor name, followed by a + and the line
number, followed by the file name. If your editor does not accept the
"+linenumber" syntax, or has other differences in invocation syntax,
the LESSEDIT variable can be changed to modify this default.
SECURITY
When the environment variable LESSSECURE is set to 1, less runs in a
"secure" mode. This means these features are disabled:
! the shell command
| the pipe command
:e the examine command.
v the editing command
s -o log files
-k use of lesskey files
-t use of tags files
metacharacters in filenames, such as *
filename completion (TAB, ^L)
Less can also be compiled to be permanently in "secure" mode.
COMPATIBILITY WITH MORE
If the environment variable LESS_IS_MORE is set to 1, or if the program
is invoked via a file link named "more", less behaves (mostly) in con-
formance with the POSIX "more" command specification. In this mode,
less behaves differently in these ways:
The -e option works differently. If the -e option is not set, less
behaves as if the -E option were set. If the -e option is set, less
behaves as if the -e and -F options were set.
The -m option works differently. If the -m option is not set, the
medium prompt is used, and it is prefixed with the string "--More--".
If the -m option is set, the short prompt is used.
The -n option acts like the -z option. The normal behavior of the -n
option is unavailable in this mode.
The parameter to the -p option is taken to be a less command rather
than a search pattern.
The LESS environment variable is ignored, and the MORE environment
variable is used in its place.
ENVIRONMENT VARIABLES
Environment variables may be specified either in the system environment
as usual, or in a lesskey (1) file. If environment variables are
defined in more than one place, variables defined in a local lesskey
file take precedence over variables defined in the system environment,
which take precedence over variables defined in the system-wide lesskey
file.
COLUMNS
Sets the number of columns on the screen. Takes precedence over
the number of columns specified by the TERM variable. (But if
you have a windowing system which supports TIOCGWINSZ or
WIOCGETD, the window system’s idea of the screen size takes
precedence over the LINES and COLUMNS environment variables.)
EDITOR The name of the editor (used for the v command).
HOME Name of the user’s home directory (used to find a lesskey file
on Unix and OS/2 systems).
HOMEDRIVE, HOMEPATH
Concatenation of the HOMEDRIVE and HOMEPATH environment vari-
ables is the name of the user’s home directory if the HOME vari-
able is not set (only in the Windows version).
INIT Name of the user’s init directory (used to find a lesskey file
on OS/2 systems).
LANG Language for determining the character set.
LC_CTYPE
Language for determining the character set.
LESS Options which are passed to less automatically.
LESSANSIENDCHARS
Characters which may end an ANSI color escape sequence (default
"m").
LESSANSIMIDCHARS
Characters which may appear between the ESC character and the
end character in an ANSI color escape sequence (default
"0123456789;[?!"’#%()*+ ".
LESSBINFMT
Format for displaying non-printable, non-control characters.
LESSCHARDEF
Defines a character set.
LESSCHARSET
Selects a predefined character set.
LESSCLOSE
Command line to invoke the (optional) input-postprocessor.
LESSECHO
Name of the lessecho program (default "lessecho"). The lessecho
program is needed to expand metacharacters, such as * and ?, in
filenames on Unix systems.
LESSEDIT
Editor prototype string (used for the v command). See discus-
sion under PROMPTS.
LESSGLOBALTAGS
Name of the command used by the -t option to find global tags.
Normally should be set to "global" if your system has the global
(1) command. If not set, global tags are not used.
LESSHISTFILE
Name of the history file used to remember search commands and
shell commands between invocations of less. If set to "-" or
"/dev/null", a history file is not used. The default is
"$HOME/.lesshst" on Unix systems, "$HOME/_lesshst" on DOS and
Windows systems, or "$HOME/lesshst.ini" or "$INIT/lesshst.ini"
on OS/2 systems.
LESSHISTSIZE
The maximum number of commands to save in the history file. The
default is 100.
LESSKEY
Name of the default lesskey(1) file.
LESSKEY_SYSTEM
Name of the default system-wide lesskey(1) file.
LESSMETACHARS
List of characters which are considered "metacharacters" by the
shell.
LESSMETAESCAPE
Prefix which less will add before each metacharacter in a com-
mand sent to the shell. If LESSMETAESCAPE is an empty string,
commands containing metacharacters will not be passed to the
shell.
LESSOPEN
Command line to invoke the (optional) input-preprocessor.
LESSSECURE
Runs less in "secure" mode. See discussion under SECURITY.
LESSSEPARATOR
String to be appended to a directory name in filename comple-
tion.
LESSUTFBINFMT
Format for displaying non-printable Unicode code points.
LESS_IS_MORE
Emulate the more (1) command.
LINES Sets the number of lines on the screen. Takes precedence over
the number of lines specified by the TERM variable. (But if you
have a windowing system which supports TIOCGWINSZ or WIOCGETD,
the window system’s idea of the screen size takes precedence
over the LINES and COLUMNS environment variables.)
PATH User’s search path (used to find a lesskey file on MS-DOS and
OS/2 systems).
SHELL The shell used to execute the ! command, as well as to expand
filenames.
TERM The type of terminal on which less is being run.
VISUAL The name of the editor (used for the v command).
SEE ALSO
lesskey(1)
COPYRIGHT
Copyright (C) 1984-2009 Mark Nudelman
less is part of the GNU project and is free software. You can redis-
tribute it and/or modify it under the terms of either (1) the GNU Gen-
eral Public License as published by the Free Software Foundation; or
(2) the Less License. See the file README in the less distribution for
more details regarding redistribution. You should have received a copy
of the GNU General Public License along with the source for less; see
the file COPYING. If not, write to the Free Software Foundation, 59
Temple Place, Suite 330, Boston, MA 02111-1307, USA. You should also
have received a copy of the Less License; see the file LICENSE.
less is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FIT-
NESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
more details.
AUTHOR
Mark Nudelman
See http://www.greenwoodsoftware.com/less/bugs.html for the latest list
of known bugs in less.
Send bug reports or comments to the above address or to
bug-less@gnu.org.
For more information, see the less homepage at
http://www.greenwoodsoftware.com/less.
Version 436: 07 Jul 2009 LESS(1)