Insert line numbers in files painlessly with nl
Was trying to figure out how to insert line numbers into a huge file with sed or awk, then stumbled across "nl", a sweet little baby that comes with GNU coreutils and numbering files is what it does for a living. GNU coreutils is full of gems!
ak@gd:~$ cat file blah blah blah bleh blah
ak@gd:~$ cat file | nl -n ln -w1 -s\| 1|blah 2|blah blah 3|bleh blah
More awesome (avoids UUOC):
ak@gd:~$ nl -n ln -w1 -s\| file 1|blah 2|blah blah 3|bleh blah