[TUHS] Line Numbers Before SysIII nl? BSD num?

segaloco via TUHS tuhs at tuhs.org
Sat Jul 23 17:55:59 AEST 2022

> On Friday, July 22nd, 2022 at 10:56 PM, markus schnalke <meillo at marmaro.de> wrote:
> As I'm currently thinking a lot about ed, this comes to mind:
> echo 23,42n | ed - file

The n rule is actually what lead me to studying nl.  It's also supported in System III but not V7, although ed's n does show up in V8-V10.  The implementation looks similar although integrated slightly differently.  Probably from the same source though.

There's also an implementation in 4.4BSD-Lite, although plan old 4.4 with the AT&T encumbered ed doesn't implement n.

So a rough timeline I can see for line number filters based on source code, old docs, etc:

1977 - num and ex's '#' commands are introduced for 2BSD release
1980 - nl and ed's 'n' commands are introduced in System III
1980 - num's trail goes dark between 4 and 4.1c BSD
1982 - System V adopts ex, including '#'
1985 - Research has adopted ed with n by now as well as ex, never adopts nl
1992 - POSIX.2 is released, codifying nl, ed with n, and ex with #
1992 - nl appears in GNU fileutils
1994 - 4.4BSD-Lite ed includes n
1999 - NetBSD 1.4 adds nl
2002 - FreeBSD 4.5 adds nl
2005 - MacOSX 10.4 with text_cmds-47 adds nl
2013 - MINIX 3.2.1 adopts NetBSD nl
2014 - OpenBSD 5.5 adds nl

So all in all, num was an attempt that petered out, but # stayed in ex.  System III and 4.4BSD-Lite ed derivatives implement n, and nl was introduced in System III for the AT&T line and slowly cropped up elsewhere.  System V picked up ex in 1982, allowing nl, ed with n, and ex with # in the AT&T line.  GNU had one out of the gate when POSIX hit.  BSDs were late to the party with regards to both ed with n as well as nl, with nl only being adopted after the last Berkeley releases and subsequent fracturing.

So thus far it seems the earliest line numberer to see wide use was probably ex's #.  System III's nl became the ubiquitous tool for the job and was then slowly adopted elsewhere.  Ed rides a fine middle ground with the n command that saw wider adoption earlier.  I still have to wonder if there was something earlier though.

- Matt

More information about the TUHS mailing list