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

Tomasz Rola rtomek at ceti.pl
Mon Jul 25 05:02:53 AEST 2022


On Sat, Jul 23, 2022 at 08:00:10AM -0400, Dan Cross wrote:
> On Sat, Jul 23, 2022 at 7:20 AM John Cowan <cowan at ccil.org> wrote:
[...]
> > An obvious approach, which would leave no real traces in documentation, would be:
> >
> > $ awk '{print NR, $0}'
> >
> > A more precise emulation would be more of a pain to type:
> >
> > $ awk '{printf("%6d\t%s\n", NR, $0)}'
> >
> > but perfectly usable in a script.
> 
> Yes, but awk wasn't widely available until 7th edition. I imagine work
> on it began before `num` in 2BSD, but few outside of Bell Labs would
> have seen it prior to 1978 or so.
> 
> I wonder if the use-case was just sufficiently rare that no one felt like
> building a special tool and it was just done on an ad-hoc basis, if
> necessary.

My sed-fu is only rudimentary but after  banging my head against
monitor a bit, I came up with this:

$  wc -l c.lisp 
90 c.lisp

$  cat c.lisp | sed -e '{=;}' | sed -e 'N;s/\n/ /'

Seems to print what is needed. Now, just embed it in sh script. A
program in C could be longer, and required a compiler.

-- 
Regards,
Tomasz Rola

--
** A C programmer asked whether computer had Buddha's nature.      **
** As the answer, master did "rm -rif" on the programmer's home    **
** directory. And then the C programmer became enlightened...      **
**                                                                 **
** Tomasz Rola          mailto:tomasz_rola at bigfoot.com             **


More information about the TUHS mailing list