How to add line numbers to a text file?
Dan Bernstein
brnstnd at kramden.acf.nyu.edu
Sat Dec 1 08:25:25 AEST 1990
In article <rhoward.659993691 at romeo> rhoward at msd.gatech.edu (Robert L. Howard) writes:
> In <15248:Nov3018:01:4490 at kramden.acf.nyu.edu> brnstnd at kramden.acf.nyu.edu (Dan Bernstein) writes:
> >In article <6826 at uceng.UC.EDU> dmocsny at minerva.che.uc.edu (Daniel Mocsny) writes:
> >> My question to all of you, however, is this: faced with the need to
> >> number a text file from a shell script, how would you do it?
> >grep -n .*
> Huh? This is not even a complete answer....
Of course it is. Whatever your shell is, you want to exec grep with
arguments -n and .*. Of course, in most shells you'll have to quote the
asterisk. By assumption, the input is a text file. Why is more
information necessary?
> cat -n <infile >outfile
> (It's got to be faster than grep too)
Possibly, but I find its output format more difficult to use directly as
input to other programs.
(Yeah, that's it: echo 'set nu' >> ~/.exinit. :-) )
---Dan
More information about the Comp.unix.questions
mailing list