How to add line numbers to a text file?

Jim Balter jim at segue.segue.com
Sun Dec 2 02:51:57 AEST 1990


In article <6826 at uceng.UC.EDU> dmocsny at 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



More information about the Comp.unix.questions mailing list