less -n デフォルトの動作、manで表示されたものとは異なる

less -n デフォルトの動作、manで表示されたものとは異なる

MacOS および Ubuntu Server 20 の場合、コマンドを使用すると次の内容をman less読むことができます。

 -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 cur‐
              rent 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.

この投稿の理由は、-nウィジェットの(小文字)パラメータを含めることですThe default (to use line numbers)。上記の2つのオペレーティングシステムに対して次のことを行います。

  • less /path/to/filename.txt

行番号なしでデータを表示します。見られるものとは対照的に以上。

もちろん、私が使用した行番号を見るには、次のようにします。

  • less -N /path/to/filename.txt

指示通りに動作します。だから:

less    /path/to/filename.txt
less -n /path/to/filename.txt

ほぼ同じです。

私は何を逃したことがありませんか?

ところで、less --help

-n  -N  ....  --line-numbers  --LINE-NUMBERS
                  Don't use line numbers.

あまり明確ではなく、とても混乱しています。

次の貴重な投稿のためにこの記事を作成しました。

ソリューションの状態は次のとおりです。

You can, however, run "less -n +F", which causes "less" to read 
only the end of the file, at the cost of **not** displaying line numbers

ベストアンサー1

less2 つの方法で行番号を表示します。

  • 各行の先頭に-Nif;を使用してください。
  • 詳細なプロンプトがアクティブになると、画面下部のステータス行に表示されます(less -M;表示された行の最初、最後、および総数が表示されます)。

-n前者と同様に、後者も無効にします。特に、行の総数を決定するのに費用がかかる可能性があるため、このオプションは便利です。無効な行番号を使用している場合は、-nファイルlessの場所をバイト単位で表示します。

私のバージョンにはless次のものがありますless --help

  -n  ........  --line-numbers
                  Don't use line numbers.
  -N  ........  --LINE-NUMBERS
                  Use line numbers.

-n表示されるメッセージに記載されている動作は次のとおりです。

行番号を使用することは、行番号が詳細なプロンプトおよび=コマンドに表示され、vコマンドが現在の行番号をエディタに渡すことを意味します。

各行の先頭に行番号は記載されていません。

おすすめ記事