How to add line numbers to a text file?
Robert L. Howard
rhoward at msd.gatech.edu
Sat Dec 1 06:34:51 AEST 1990
In <15248:Nov3018:01:4490 at kramden.acf.nyu.edu> brnstnd at kramden.acf.nyu.edu (Dan Bernstein) writes:
>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?
>grep -n .*
Huh? This is not even a complete answer....
Try:
cat -n <infile >outfile
(It's got to be faster than grep too)
Robert
--
| Robert L. Howard | Georgia Tech Research Institute |
| rhoward at msd.gatech.edu | MATD Laboratory |
| (404) 528-7165 | Atlanta, Georgia 30332 |
| UUCP: ...!{allegra,amd,hplabs,ut-ngp}!gatech!msd!rhoward |
-------------------------------------------------------------------------
| "They [La Prensa] accused us of suppressing freedom of |
| expression. This was a lie and we could not let them |
| publish it." -- Nelba Blandon, Director of Censorship |
More information about the Comp.unix.questions
mailing list