The documentation for POSIX tail's -n
option says that
The origin for counting shall be 1; that is, -n +1 represents the first line of the file, -n -1 the last.
So tail -n 10
(used later on the same page) and tail -n -10
should print the last ten lines, and tail -n +10
would skip the first nine lines and print all the rest.
The documentation for POSIX head's -n
option says that
The application shall ensure that the number option-argument is a positive decimal integer.
So head -n -10
and head -n +10
are not POSIX compatible because the values -10
and +10
are not simple integers but rather strings with no special meaning in the shell, and there's no way to print all lines until the Nth last one. Why the discrepancy?
PS: head -n +10
works with GNU coreutils.