Last Update 2014/03/11
ファイルを表示します。サイズが大きなファイルでも複数行単位の表示が可能です。
less オプション1 ファイルパス1
操作コマンド(moreのヘルプ参照)
※数値kはコマンドの前に数値を付けた際に指定される
h, H ヘルプ表示
q, :q, Q, :Q, ZZ 終了
e, ctrl-E, j, ctrl-N, CR テキストの次のk行を表示
デフォルト:1
y, ctrl-Y, k, ctrl-K, ctrl-P テキストの前のk行を表示
デフォルト:1
f, ctrl-F, ctrl-V, space テキストの次のk行を表示
デフォルト:現在のスクリーンサイズ
b, ctrl-B, esc-v テキストの前のk行を表示
デフォルト:現在のスクリーンサイズ
z テキストの次のk行を表示
デフォルト:現在のスクリーンサイズ(k値上書き)
w テキストの前のk行を表示
デフォルト:現在のスクリーンサイズ(k値上書き)
d, ctrl-D テキストの次のk行を表示
デフォルト:現在のスクリーンサイズの1/2(k値上書き)
u, ctrl-U テキストの前のk行を表示
デフォルト:現在のスクリーンサイズの1/2(k値上書き)
esc-), 右矢印キー 画面をk文字右スクロール
デフォルト:現在のスクリーンサイズの1/2(k値上書き)
esc-(, 左矢印キー 画面をk文字左スクロール
デフォルト:現在のスクリーンサイズの1/2(k値上書き)
r, ctrl-R, ctrl-L 再描画
/パターン パターンにk回目にマッチした文字列へ前方移動
デフォルト:1
?パターン パターンにk回目にマッチした文字列へ後方移動
デフォルト:1
n 前回検索したパターンでk回目にマッチした文字列へ前方移動
デフォルト:1
N 前回検索したパターンでk回目にマッチした文字列へ後方移動
デフォルト:1
esc-n 前回検索したパターンでk回目にマッチした文字列へ前方移動
(複数ファイル間可能)
デフォルト:1
esc-N 前回検索したパターンでk回目にマッチした文字列へ後方移動
(複数ファイル間可能)
デフォルト:1
esc-u 検索結果のハイライト表示をオフにする
&パターン パターンにマッチした行のみを表示
g, < ファイルのk行目に移動
デフォルト:1
G, > ファイルのk行目に移動
デフォルト:ファイルの終わり
p, % ファイルのkパーセントの位置へ移動
デフォルト:0
:e ファイルのリストへの新しいファイルの読み込み
:n k個先のファイルに移動
デフォルト:1
:p k個前のファイルに移動
デフォルト:1
:x 最初のファイルに移動
:d ファイルのリストから現在のファイルを削除
= 現在のファイルについての情報の表示
:f 現在のファイル名と行数を表示
- 続けて入力したオプション文字に対応するオプションの
設定を変更し、変更内容の情報を表示
_(下線) 続けて入力したオプション文字に対応するオプションの
設定内容の表示
v 現在行でエディタ起動
デフォルト:vi
※ オプションなどは個人的に重要と考えられるものを記述しており、記載の無いものは、manページや関連書籍などを参照願います。
※ 実行例の記述は、不要と考えられる部分の削除などの修正を行ったものを掲載しています。
※ 実行例の実行環境はUbuntu 12.10です。
※ 実行例の記述は、不要と考えられる部分の削除などの修正を行ったものを掲載しています。
※ 実行例の実行環境はUbuntu 12.10です。
(例) オプション無し
$ less /usr/include/stdio.h
実行結果(10行表示の場合)
/* Define ISO C stdio on top of C++ iostreams.
Copyright (C) 1991, 1994-2010, 2011 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
/usr/include/stdio.h
$ less -5 /usr/include/stdio.h
実行結果(上記コマンド入力直後、10行表示の場合)
$ less -5 /usr/include/stdio.h ← この行は画面外
/* Define ISO C stdio on top of C++ iostreams.
Copyright (C) 1991, 1994-2010, 2011 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
/usr/include/stdio.h
実行結果(引き続きspace入力)
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
:
$ less -?
実行結果
SUMMARY OF LESS COMMANDS
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.
---------------------------------------------------------------------------
MOVING
e ^E j ^N CR * Forward one line (or N lines).
y ^Y k ^K ^P * Backward one line (or N lines).
f ^F ^V SPACE * Forward one window (or N lines).
b ^B ESC-v * Backward one window (or N lines).
z * Forward one window (and set window to N).
w * Backward one window (and set window to N).
ESC-SPACE * Forward one window, but don't stop at end-of-file.
d ^D * Forward one half-window (and set half-window to N).
u ^U * Backward one half-window (and set half-window to N).
ESC-) RightArrow * Left one half screen width (or N positions).
ESC-( LeftArrow * Right one half screen width (or N positions).
HELP -- Press RETURN for more, or q when done
$ less -g /usr/include/stdio.h
実行結果(/typedef で検索)
typedef struct _IO_FILE FILE; ← 検索結果をハイライト表示
__END_NAMESPACE_STD
#if defined __USE_LARGEFILE64 || defined __USE_SVID || defined __USE_POSIX \
|| defined __USE_BSD || defined __USE_ISOC99 || defined __USE_XOPEN \
|| defined __USE_POSIX2
__USING_NAMESPACE_STD(FILE)
#endif
# define __FILE_defined 1
:
$ less -i -g /usr/include/stdio.h
実行結果(/null で検索)
# define __need_NULL
# include
# include
# define __need_FILE
# define __need___FILE
#endif /* Don't need FILE. */
:
実行結果(/Null で検索)
/* Define ISO C stdio on top of C++ iostreams.
Copyright (C) 1991, 1994-2010, 2011 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
Pattern not found (press RETURN)
$ less -I -g /usr/include/stdio.h
実行結果(/Null で検索)
# define __need_NULL
# include
# include
# define __need_FILE
# define __need___FILE
#endif /* Don't need FILE. */
:
$ less -g -j5 /usr/include/stdio.h
実行結果(/typedef で検索)
struct _IO_FILE;
__BEGIN_NAMESPACE_STD
/* The opaque type of streams. This is the definition used elsewhere. */
typedef struct _IO_FILE FILE;
__END_NAMESPACE_STD
#if defined __USE_LARGEFILE64 || defined __USE_SVID || defined __USE_POSIX \
|| defined __USE_BSD || defined __USE_ISOC99 || defined __USE_XOPEN \
|| defined __USE_POSIX2
:
$ less -w /usr/include/stdio.h
実行結果(spaceで次ページ移動直後)
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, write to the Free
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA. */
:
$ less -W /usr/include/stdio.h
実行結果(コマンド5eで5行移動直後)
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
: