Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!samsung!usc!sdd.hp.com!zaphod.mps.ohio-state.edu!maverick.ksu.ksu.edu!ux1.cso.uiuc.edu!news.cs.indiana.edu!uceng!schriste From: schriste@uceng.UC.EDU (Steven V. Christensen) Newsgroups: comp.unix.questions Subject: Re: How to add line numbers to a text file? Message-ID: <6829@uceng.UC.EDU> Date: 30 Nov 90 19:11:24 GMT References: <6826@uceng.UC.EDU> Organization: Univ. of Cincinnati, College of Engg. Lines: 32 dmocsny@minerva.che.uc.edu (Daniel Mocsny) writes: >I need to add line numbers to a text file. >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? Under SunOS I would type: cat -n filename > wherever Or under most any Unix: awk -e '{print NR, " ",$0}' filename > wherever Happy hacking! Steven >-- >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 -- Steven V. Christensen U.C. College of Eng. schriste@uceng.uc.edu For the adventurous: svc@elf0.uucp