对于MacOS和Ubuntu 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) (小写)参数。对于提到的这两个操作系统,如果我这样做的话:
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发布于 2022-01-21 13:05:32
less以两种方式显示行号:
-N;less -M;这将显示显示的第一行数、最后一行和总行数)。-n禁用了后者,以及前者。特别是,确定行的总数可能很昂贵;这就是为什么这个选项是有用的。使用-n禁用行号时,less以字节显示文件中的位置。
我的less版本在less --help中有以下内容:
-n ........ --line-numbers
Don't use line numbers.
-N ........ --LINE-NUMBERS
Use line numbers.您显示的信息描述了-n的行为:
使用行号意味着:行号将显示在详细提示符和=命令中,v命令将当前行号传递给编辑器
这没有提到每行开头的行号。
https://unix.stackexchange.com/questions/687315
复制相似问题