Search This Blog

Wednesday, February 4, 2009

Adding line numbers in a file

nl
nl (1) - number lines of files
nl (1p) - line numbering filter
nl [curs_outopts] (3x) - curses output options

if v is a file

1) cat v | nl
2) nl v
3) nl -i10 -nrz -s:: -v10 -w3 v
4) cat -a v
5) cat -n v
6) awk '{ print NR" "$0 }' v
7) sed = v | sed 'N;s/\n/ /'

redirect the output

No comments:

Post a Comment