Created
June 3, 2011 07:54
-
-
Save nobeans/1006025 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
final COUNT_TO_WRITE = 5 | |
def lineNo = 1 | |
def writableCount = 0 | |
System.in.eachLine { | |
if (it =~ /hoge/) { | |
writableCount = COUNT_TO_WRITE | |
} | |
if (writableCount > 0) { | |
println "$lineNo: $it" | |
writableCount-- | |
} | |
lineNo++ | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Alternative implementation of "grep -A".
I recommend to use the groovyclient of GroovyServ instead of groovy!