Advertisement
Guest User

Untitled

a guest
Dec 11th, 2016
218
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.83 KB | None | 0 0
  1. List l = new ArrayList{a@yahoo.com, b@gmail.com}
  2. def gmail = ['sh','-c','grep "clientLogin="$l.get(0) file.txt' | grep gmail | wc -l ]
  3. def yahoo = ['sh','-c','grep "clientLogin="$l.get(1) file.txt' | grep yahoo| wc -l ]
  4.  
  5. def gmail = ['sh','-c','grep "clientLogin=${l.get(0)}" file.txt' | grep gmail | wc -l ]
  6.  
  7. def gmail = ['sh','-c','grep "clientLogin=a@yahoo.com" file.txt' | grep gmail | wc -l ]
  8.  
  9. Into the domain clientLogin=a@yahoo.com exit on 12/01/2008 etc..
  10.  
  11. def ex = ['sh','-c','grep "domain clientLogin=$client" file.txt'| grep "something more" | wc -l]
  12.  
  13. def ex = ['grep', "$client", 'file.txt']
  14.  
  15. def file = new File("file.txt")
  16. file.delete() // clear out old version for multiple runs
  17. file << """
  18. foobar clientLogin=a@yahoo.com baz quux # should match a@yahoo.com
  19. foobar email=a@yahoo.com baz quux
  20. foobar email=b@gmail.com bal zoom
  21. foobar clientLogin=a@yahoo.com baz quux # should match a@yahoo.com
  22. foobar clientLogin=b@gmail.com bal zoom # should match b@gmail.com
  23. foobar email=b@gmail.com bal zoom
  24. """
  25.  
  26. def emailList = ["a@yahoo.com", "b@gmail.com"]
  27. def emailListGroup = emailList.join('|')
  28. def pattern = /(?m)^.*clientLogin=($emailListGroup).*$/
  29.  
  30. def resultMap = [:]
  31.  
  32. (file.text =~ pattern).each { fullLine, email ->
  33. resultMap[email] = resultMap[email] ? resultMap[email] + 1 : 1
  34. }
  35.  
  36. assert resultMap["a@yahoo.com"] == 2
  37. assert resultMap["b@gmail.com"] == 1
  38.  
  39. def client = 'foo@bar.com'
  40. def ex = ['grep', "$client", 'file.txt']
  41.  
  42. def proc = ex.execute()
  43. proc.waitFor()
  44.  
  45. println "return: ${proc.exitValue()}"
  46. println "stderr: ${proc.err.text}"
  47. println "stdout: ${proc.in.text}"
  48.  
  49. "${l.get(0)}"
  50.  
  51. List l = new ArrayList{a@yahoo.com, b@gmail.com}
  52. def gmail = ['sh','-c','grep "clientLogin="${l.get(0)} file.txt' | grep gmail | wc -l ]
  53. 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