Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!swrinde!zaphod.mps.ohio-state.edu!usc!randvax!segue!jim From: jim@segue.segue.com (Jim Balter) Newsgroups: comp.unix.questions Subject: Re: How to add line numbers to a text file? Message-ID: <4905@segue.segue.com> Date: 1 Dec 90 15:51:57 GMT References: <6826@uceng.UC.EDU> <15248:Nov3018:01:4490@kramden.acf.nyu.edu> Reply-To: jim@segue.segue.com (Jim Balter) Organization: Segue Software, Inc. - Santa Monica, CA. +1-213-453-2161 Lines: 12 In article <6826@uceng.UC.EDU> dmocsny@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? 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? pr -tn filename grep -n $ filename If you simply RTFM (permuted index), you'll find nl filename on PWB/SVID based systems, and num filename (cat -n) on BSD