Path: utzoo!censor!geac!torsqnt!news-server.csri.toronto.edu!rutgers!usc!samsung!uunet!mcsun!unido!pemstgt!ralfi From: ralfi@pemstgt.PEM-Stuttgart.de (Ralf Holighaus) Newsgroups: comp.unix.questions Subject: Re: How to add line numbers to a text file? Message-ID: <1990Dec02.125400.16374@pemstgt.PEM-Stuttgart.de> Date: 2 Dec 90 12:54:00 GMT References: <6826@uceng.UC.EDU> Organization: PEM Tillmann Basien, Stuttgart, Germany Lines: 37 dmocsny@minerva.che.uc.edu (Daniel Mocsny) writes: >I need to add line numbers to a text file. I am processing the text file >from a Bourne shell script. I know that I can write a C program that >reads each line of standard input with gets(), increments a line >counter, and then prints the line counter and line to standard output. >If I call the program number.c, then I can put a line in my shell >script like: > number < $TEXTFILE > $NUMBEREDFILE >I could also write a one-line awk script, but because I am much more >familiar with C than awk, almost every time I try to do something simple >in awk I wind up taking longer. >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? I'm >kind of curious to see the variety of approaches possible. Would you >use C, awk, perl, sed, sh, cat, echo, expr, and/or dd? >-- >Dan Mocsny Snail: >Internet: dmocsny@minerva.che.uc.edu Dept. of Chemical Engng. M.L. 171 > dmocsny@uceng.uc.edu University of Cincinnati >513/751-6824 (home) 513/556-2007 (lab) Cincinnati, Ohio 45221-0171 HOW ABOUT USING THE NL COMMAND AVAILABLE ON THE UNIX SYSTEM??? rgds Ralf. -- Programmentwicklung fuer Microcomputer | Ralf U. Holighaus PO-Box 810165 Vaihinger Strasse 49 | >> PEM Support << D-7000 Stuttgart 80 West Germany | holighaus@pemstgt.PEM-Stuttgart.de VOICE: x49-711-713045 FAX: x49-721-713047 | ..!unido!pemstgt!ralfi