How to add line numbers to a text file?
Doug Gwyn
gwyn at smoke.brl.mil
Sat Dec 1 11:38:34 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:
>>> number a text file from a shell script, how would you do it? I'm
>>grep -n .*
>Huh? This is not even a complete answer....
Actually, it's a pretty good answer, because it immediately leads one to
appreciate that the numbering can be tailored somewhat so that, for
instance, only non-blank lines are numbered, merely by altering the
search pattern.
0
>Try:
>>cat -n <infile >outfile
>(It's got to be faster than grep too)
It sure is faster:
$ cat -n
cat: illegal option -- n
usage: cat -usvte [-|file] ...
The job of "cat" is to concatenate files, not to translate them. (The
"-v" option (along with "-t" and "-e") is an abomination added at UCB.)
The best versions of "cat" have no options at all; they aren't needed.
More information about the Comp.unix.questions
mailing list