I was recently reading More shell, less egg and ran across this:
(I can't help wondering, though, why [Doug McIlroy] didn't use
head -${1}in the last line. It seems more natural thansed. Is it possible thatheadhadn't been written yet?)
While
head
postdates
sed
, this is probably not it. There is an old Unix bias against using
head
to the point that a lot of old Unix people make a point of avoiding it in favour of
sed
.
This isn't a technical issue as much as a cultural issue.
head
was introduced in 4BSD, and there has always been a reaction against 4BSD that saw it as the point where the core Unix philosophy started being lost. The introduction of a documented command that could as well be a shell script (the original version only limited things by line) was often seen as yet another example of BSD not really getting the point of things. To put it one way, Unix was not about having a system command for everything; it was about a kind of near-mathematical minimalism. Given
sed
, the basic 4BSD version of
head
is not minimal at all.
(
tail
was different because you can't duplicate it with
sed
or anything else feasible; it did a unique job. I suspect that this is part of why
tail
appears in V7.)
I'm not quite old enough in my Unix exposure to have been part of this first hand, but I was apparently exposed to enough old Unix hands at a sensitive age to have picked this up as a reflexive habit. To this day, I use '
sed Nq
' instead of
head
. It just feels (more) right.
Sidebar: would McIlroy have had
head
available?
The short version is 'probably not'. The bit that's being quoted is from 1986, well after 4BSD introduced
head
, but McIlroy was at Bell Labs and was almost certainly using Research Unix . While the version of Research Unix from that era used a kernel derived from 4BSD, my impression is that most of the userland programs were basically V7 and I would be somewhat surprised if the Bell Labs people had picked up
head
.