Hi Stahlman!

On Mi, 14 Apr 2010, Stahlman Family wrote:

> John Little wrote:
>> Assuming the pattern /^-$/ matches lines 1,7,13,19 and so on, you can
>> use g with relative line numbers to delete lines.
>>
>> For File A, copy and use
>>
>> :g/^-$/d2|+,+3d
>>
>> for File B, copy and use
>>
>> :g/^-$/d3|+,+2d
>>
>> for File C, copy and use
>>
>> :g/^-$/d4|+d
>>
>> for File D, copy and
>>
>> :g/^-$/d5
>
> Or, to do it all in one fell swoop from the shell...
>
> for i in 3 4 5 6; do sed -n $i~6p test.txt >test$((i-2)).out; done
>
> You could do the same thing from within Vim by editing the file and doing...
> :w !sed -n '3~6p' >test1.out
> :w !sed -n '4~6p' >test2.out
> .
> .
>
> In my opinion, these approaches are a bit simpler, but of course, they  
> work only if you have POSIX tools on your system...

Actually, this only works with GNU sed. The "~"-adressing is a specialty 
that is not required by POSIX and I am not sure which other sed support 
it.

regards,
Christian

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

To unsubscribe, reply using "remove me" as the subject.

Reply via email to