At the beginning, it was just head(1), easy and simple; print the first n lines (by default 10) and exist. But most programmers and users wanted a way to reverse the operation and print the last 10 lines instead, so the tail(1) utility was added.
tail(1) was as simple as head(1), but devs wanted more. They added the -c BYTES
option to print the last BYTES instead of lines. And also added the -f
option to continue reading after EOF. If this was not enough complicated for a simple "counter"-util, they also added the ability to use offsets from the start/end of the file; e.g., -n+10
to print every line after line number 10.
Now we're at the current day; POSIX-1.2024, the waited one, has just released publicly in web format. A lot of changes to utilities are made, especially for pathnames. POSIX(®) now allows the utility to refuse operations on paths containing a <newline> character. Once I checked head(1) & tail(1), I found out they added -c BYTES
to head(1) to print the first BYTES instead of lines! But they added a very weird thing to tail(1). The -r
to reverse output (the full file by default).
What? Why? And why in tail(1) and not just add another utility? In the RATIONALE section, they stated that "more implementations that have achived POSIX certification had already implemented tail -r
as an extention". One last thing, the -r
option does not exist in GNU's tail(1) nor in BusyBox's tail(1)!