
我剛剛在一本書上讀到該命令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.