Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- List l = new ArrayList{a@yahoo.com, b@gmail.com}
- def gmail = ['sh','-c','grep "clientLogin="$l.get(0) file.txt' | grep gmail | wc -l ]
- def yahoo = ['sh','-c','grep "clientLogin="$l.get(1) file.txt' | grep yahoo| wc -l ]
- def gmail = ['sh','-c','grep "clientLogin=${l.get(0)}" file.txt' | grep gmail | wc -l ]
- def gmail = ['sh','-c','grep "clientLogin=a@yahoo.com" file.txt' | grep gmail | wc -l ]
- Into the domain clientLogin=a@yahoo.com exit on 12/01/2008 etc..
- def ex = ['sh','-c','grep "domain clientLogin=$client" file.txt'| grep "something more" | wc -l]
- def ex = ['grep', "$client", 'file.txt']
- def file = new File("file.txt")
- file.delete() // clear out old version for multiple runs
- file << """
- foobar clientLogin=a@yahoo.com baz quux # should match a@yahoo.com
- foobar email=a@yahoo.com baz quux
- foobar email=b@gmail.com bal zoom
- foobar clientLogin=a@yahoo.com baz quux # should match a@yahoo.com
- foobar clientLogin=b@gmail.com bal zoom # should match b@gmail.com
- foobar email=b@gmail.com bal zoom
- """
- def emailList = ["a@yahoo.com", "b@gmail.com"]
- def emailListGroup = emailList.join('|')
- def pattern = /(?m)^.*clientLogin=($emailListGroup).*$/
- def resultMap = [:]
- (file.text =~ pattern).each { fullLine, email ->
- resultMap[email] = resultMap[email] ? resultMap[email] + 1 : 1
- }
- assert resultMap["a@yahoo.com"] == 2
- assert resultMap["b@gmail.com"] == 1
- def client = 'foo@bar.com'
- def ex = ['grep', "$client", 'file.txt']
- def proc = ex.execute()
- proc.waitFor()
- println "return: ${proc.exitValue()}"
- println "stderr: ${proc.err.text}"
- println "stdout: ${proc.in.text}"
- "${l.get(0)}"
- List l = new ArrayList{a@yahoo.com, b@gmail.com}
- def gmail = ['sh','-c','grep "clientLogin="${l.get(0)} file.txt' | grep gmail | wc -l ]
- def yahoo = ['sh','-c','grep "clientLogin="${l.get(1)} file.txt' | grep yahoo| wc -l ]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement