hi Chris,
thanks for quick response.
yes I didn't say it clear.
actually the latter as you mentioned is exactly what I want:

"

Or if you want to print lines from the "classifier-group" line until the
next matching line "xxx" packets, xxx bytes", use this command:

:g/classifier-group/.,/\d\d* packets, \d\d* bytes/p

(Which boils down to on each line matching classifier-group" print from
there until the next line, matching '\d\d packets, \d\d bytes' using the
:p command.)

"
to be more precise , I want to extract only those adjacent lines like following,

    classifier-group jnpr-VIDEO-TRAFFIC entry 2
      0 packets, 0 bytes

but only if the packets, bytes are NON-zero. so I modified your command to:

:g/classifier-group/.,/[1-9]\d* packets, [1-9]\d* bytes/p

Looks I don't get anything after that, do I miss anything here?


thanks!

regards
ping



On 06/14/2012 04:50 PM, Christian Brabandt wrote:
Hi ping!

On Do, 14 Jun 2012, ping wrote:

see I want to extract certain line from following text, and only
display those lines for me.
usually I use :global to do that job and it works fine.
but the specialty here is, I want to search "across" lines:
I want to get ONLY lines containing either of these:

    "classifier-group"
    OR
    xxx packets, xxx bytes

where xxx can be any NUMBERS.

so I use this after visual selection:

:'<,'>g/classifier-group\_.\{-}\d\d* packets, \d\d* bytes

but I only get these:
:'<,'>g/classifier-group\_.\{-}\d\d* packets, \d\d* bytes

I am not sure I understand, which of 2 different problems you are trying
to solve. If you wish to print lines containing either
"classifier-group" or "xxx packets, xxx bytes" use something like this
command:
:g/classifier-group\|\d\d* packets, \d\d* bytes


Or if you want to print lines from the "classifier-group" line until the
next matching line "xxx" packets, xxx bytes", use this command:

:g/classifier-group/.,/\d\d* packets, \d\d* bytes/p

(Which boils down to on each line matching classifier-group" print from
there until the next line, matching '\d\d packets, \d\d bytes' using the
:p command.)


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

Reply via email to