====== SED - Numbering - Number each line of a file (but only print numbers if line is not blank) ====== sed '/./=' filename | sed '/./N; s/\n/ /' ---- ===== Example ===== Running that command again this file: aaa bbb ccc returns: 1 aaa 2 bbb 3 ccc