Monday, April 4, 2011

Inserting Line Numbers into Existing Text

I have a file that consists of approx 400K lines and 25762K chars

this work is the result of someone who has copied existing files onto itself multiple times.

In an effort to "decrypt" this mess I am:
a) inserting .pp to indicate paragraph beginnings
b) replacing sentence endings with \r so that each line consists of one "sentence."
c) sorting all of the lines so that I can use uniq to generate a list of unique sentences.

While this works it fails to provide any context, therefore I want to insert the line number @ the beginning of each line and follow it with a tab and then have uniq ignore the first field with:
uniq --skip-fields=1

or, if I pad line numbers with leading zeros I could use:
uniq --skipchars=6

So my question is:
How do I insert the current line number into a text file; how can I do this while padding to six digits?

tia,
--Dan

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

No comments: