Wednesday, July 21, 2010

Re: gvim substitute

On 07/21/10 10:08, rudy_b wrote:
> I want to do a substitution using the (/s) command. But I am ONLY interested
> in substituting multiples of 100th line.
> In other words, I have a huge file (thousands of lines); and, I want to go
> through this file, and look for lines #100, #200, #300, #400, ... and append
> the word "checked" at the end of these line.

while others have suggested Vim solutions, if you have GNU sed,
this is pretty simple:

sed '100~100s/$/ (checked)/' <in.txt >out.txt

("starting at line 100, and every 100th line after that, perform
this substitute of the EOL with ' (checked)'" Note that this "~"
notation is a GNU extension to POSIX sed)

-tim

--
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: