Hope this helps You:
String[] ips = [
"192.168.1.2",
"192.168.1.1"
]
def ant = new AntBuilder()
def dest = new File('/tmp')
new File('.').eachFileMatch(~/access.*.log/) { log ->
ips.each { ip ->
File file = new File(dest, "${ip}.txt")
ant.copy(file: log.name, tofile: "$dest.absolutePath/${ip}.txt") {
filterchain() {
linecontains() {
contains(value: "$ip")
}
}
}
}
}