regex - How to stop a sed script if finding two start patterns before an end pattern? -


i need find revisions in subversion dump have changes pom.xml.

i'm using svndumptool print revisions, , sed filter findings.

i'm able match revision number start, need able throw away if find second matching start before find stop.

here command i’m using:

    svndumptool=~/path/to/svndumptool.py     target=specificsvn.dump      # use svndumptool read svnlog target stdin |      # sed matches start -r[0-9], such -r103, ends on pom.xml     # redirects stdout > log file target      $svndumptool log $target -v | sed -n '/r[0-9]/,/pom.xml/p' > $target.log 

considering log of this:

    -r0 | ... | ...     changed paths:     none; initialization of repo; not match     -r1 | ... | ...     changed paths:     ... not matches here     --------     -r2 | ... | ...     changed paths:     ... nor here     --------     -r3 | ... | ...     changed paths:     pom.xml     --------     -r4 | ... | ...     changed paths:     pom.xml     --------     -r5 | ... | ...     changed paths:     ... changes may or may not here     -------- 

here results.

  1. on first pass, more want:

    • i'll match on start of -r0,
    • a match on end of pom.xml -r3,
    • which prints start stop, including -r0, -r1 & -r2:

      -r0 | ... | ... changed paths: none; initialization of repo; not match -r1 | ... | ... changed paths: ... not matches here -------- -r2 | ... | ... changed paths: ... nor here -------- -r3 | ... | ... changed paths: pom.xml 
  2. on second pass, want:

    • i'll match on start of -r4,
    • a match on end of pom.xml -r4:

      -r4 | ... | ... changed paths: pom.xml 

so, think need is:

  1. if find start,
  2. and find expression matching start before finding expression matching end,
  3. then throw away first start; otherwise print.

i think this post might have answer, attempt have tried has failed.

edit: auto-correct got me, , incorrectly listed output "pom.xml" when should "pom.xml".

this might work (gnu sed):

sed '/-r[0-9]/{h;d};h;/pom.xml/!d;x' file 

this stores lines beginning -r[0-9] , thereafter in hold space, overwriting in hs newer ones until line containing pom.xml when prints such lines out.


Comments

Popular posts from this blog

java - JavaFX 2 slider labelFormatter not being used -

Detect support for Shoutcast ICY MP3 without navigator.userAgent in Firefox? -

web - SVG not rendering properly in Firefox -