3 ms·
From that:> 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
by tzs 7y ago
From that:> 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?
It's possible that it wasn't written yet. It's also possible that it did exist but he saw no reason to start using it, since "sed Nq" continued to work fine. Heck, it's even one less character to type than "head -N"!
BTW, apparently "head -N" is considered to be obsolete syntax. The man page for GNU head doesn't even mention it. It just gives this:
-c, --bytes=[-]K print the first K bytes of each file;
with the leading '-', print all but the last
K bytes of each file
-n, --lines=[-]K print the first K lines instead of the first 10;
with the leading '-', print all but the last
K lines of each file
-q, --quiet, --silent never print headers giving file names
-v, --verbose always print headers giving file names
--help display this help and exit
--version output version information and exit
The "info" documentation for GNU head does mention the "-N" form, and says it is an obsolete syntax supported for compatibility, and says if you must run on hosts that don't support the "-n N" form it is simpler to avoid "head" and use "sed Nq" instead.
On my Mac, with BSD head, the man page gives only this form:
head [-n count | -c bytes] [file ...]
Like GNU head, it accepts the -N form.