Linux head/tail 命令的手册页未显示“-LINES”参数

Linux head/tail 命令的手册页未显示“-LINES”参数

我刚刚在一本书中读到,该命令head -LINES显示文件的前 LINES 行。但是,head手册页似乎没有表明这是一个合法的参数。我想知道我遗漏了什么。

tail注意:的手册页似乎也是如此。

答案1

它不是一个标准参数;只是早期 Unix 系统的遗留问题。对于 GNU head/tail,您可以在以下位置找到更多信息info head

   For compatibility ‘head’ also supports an obsolete option syntax
‘-[NUM][bkm][cqv]’, which is recognized only if it is specified first.
NUM is a decimal number optionally followed by a size letter (‘b’, ‘k’,
‘m’) as in ‘-c’, or ‘l’ to mean count by lines, or other option letters
(‘cqv’).  Scripts intended for standard hosts should use ‘-c NUM’ or ‘-n
NUM’ instead.  If your script must also run on hosts that support only
the obsolete syntax, it is usually simpler to avoid ‘head’, e.g., by
using ‘sed 5q’ instead of ‘head -5’.

OpenBSDman head有一个较短的说明:

The historic syntax -count is supported by this implementation.

相关内容