Count lines
Howto count all lines from stdin or a file in groovy.
This is how this would look for the commandline:
def lines = 0
System.in.eachLine {
lines++
}
println lines
or for a file
def lines = 0
def fileName = "file.txt"
new File(fileName).eachLine {
lines++
}
println lines