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.

相關內容