Here is a Perl version of Numbering A File:
perl -lne 'printf "%3d : %s\n", $., $_' filename > filename.out
enumerationperl
Adding line numbers to a file is easy if you use awk or grep. Adjust the padding in the printf (%2d) for the amount of padding:
awk '{no=no+1; printf "%2d : %s\n", no, $0}' filename > filename.out
Command line taken (and slightly modified) from the UGU mailing list; credit goes to pradeep@unixguru.zzn.com.
awkenumeration
Here is a Perl version of Numbering A File:
perl -lne 'printf "%3d : %s\n", $., $_' filename > filename.out
enumerationlinesnumberingperl