
Я только что прочитал в книге, что команда head -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’.
В OpenBSD man head
есть более короткая заметка:
The historic syntax -count is supported by this implementation.