parsed.org
Numbering A File by xinu on Feb 27, 2007 11:09 AM

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
RSS