5 ms·
> I can’t help wondering, though, why he didn’t use head -${1} in the last line. It seems more natural than sed. Is it possible that head hadn’t been written ye
by luriel 15y ago
> I can’t help wondering, though, why he didn’t use head -${1} in the last line. It seems more natural than sed. Is it possible that head hadn’t been written yet?
I'm not sure when head(1) was added, but I doubt it was added by anyone in the Unix core team at Bell Labs, it certainly didn't make it to Plan 9 because it is redundant with sed as the example illustrates.
sed 11q is concise and clear, no need for shortcuts, but if you really have to, you can write your own head shell script that just calls sed.
- mbucc 15y agoaccording to OpenBSD man page, head(1) first appeared in 3.0 BSD, so that would be 1979.
- ajross 15y agosed is concise and clear if you know the command set, which was true of all developers at the time. But in the modern world, we all think in awk^H^H^Hperl^H^H^H^Hruby or whatever. On the command line, generic tools like sed, while they still work, have lost a lot of their relevance in favor of simpler stuff like head/tail which have much clearer semantics.
- sedq 15y agoGiven the choice, I think sed is more reliable. Not too long ago, in one well-regarded UNIX-like OS, it was discovered that head could not handle large files over a certain size. Mind you, it would not be an issue if head is used in a pipeline. But sed, by design, would not choke no matter how large the file, for a simple command like 1q, whether in a pipeline or not.