Add consecutive numbers succintly and elegantly to index lines

.seqnumberingvim

I usually do this

$ wc questions
  33   36 3105 questions
$ seq 1 33 > nums
$ paste nums questions
1       Content
2       ...
.
.
33      End Content

but I feel there could be faster way to do this, without the bad-looking dummy file. How with some basic *ix -tool? Any simpler way to do it? I use Vim so I am happy also with Vim-based solution but simple unix-based solution also works (actually probably better in some cases, I can always spawn inside the editor).

Below a general case.

Input

A
B
C
.
.
X

Output

1. A
2. B
3. C
.
.
N. X

Best Answer

Just for the completeness of this list, sed can also do it:

sed '=' questions | sed 'N;s/\n/. /'

Sadly the = command prints the line numbers on separate line, so only a separated sed call can beautify the formatting.

Related Question