Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!usc!sdd.hp.com!uakari.primate.wisc.edu!uflorida!haven!adm!smoke!gwyn From: gwyn@smoke.brl.mil (Doug Gwyn) Newsgroups: comp.unix.questions Subject: Re: How to add line numbers to a text file? Message-ID: <14629@smoke.brl.mil> Date: 1 Dec 90 00:38:34 GMT References: <6826@uceng.UC.EDU> <15248:Nov3018:01:4490@kramden.acf.nyu.edu> Organization: U.S. Army Ballistic Research Laboratory, APG, MD. Lines: 25 In article rhoward@msd.gatech.edu (Robert L. Howard) writes: >In <15248:Nov3018:01:4490@kramden.acf.nyu.edu> brnstnd@kramden.acf.nyu.edu (Dan Bernstein) writes: >>In article <6826@uceng.UC.EDU> dmocsny@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 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.