LoginSignup
1
2

More than 5 years have passed since last update.

メモ:less 行番号の表示、長い行は折りたたまない、ファイルの末尾まで到達したら終了

Last updated at Posted at 2016-10-18

less のオプション

よく使う less のオプションをメモ。
行番号の表示、長い行は折りたたまない、ファイルの末尾まで到達したら終了。

less -NeS <file>

オプションの説明

-N or --LINE-NUMBERS
              Causes a line number to be displayed at the beginning of each line in the display.


-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.


-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.

環境変数 $LESS をつかう

毎回タイプするのは面倒くさいので環境変数 $LESS にオプションを設定してデフォルトの振る舞いを変更できます。man をみましょう。

LESS   Options which are passed to less automatically.

さっきの例だとこれでよし。

export LESS="-NeS"

おまけ

ちな、less でファイルを開いている時に F (Shift + f, 大文字のF)をタイプすると tail -f みたいなモードに移行するのはもう語り尽くされたね。

レス!ネス!
捗れ〜。

1
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
2