I need grep for strings with a bunch of names, for example clientLogin=a@yahoo.com , clientLogin=b@gmail.com from a .txt file.
file.txt has garbage that is email=a@yahoo.com email=b@gmail.com . I need to filter them
As soon as I get these lines, I need grep for gmail and yahoo and get their number
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 ]
This does not work. How can I substitute the value of $ l.get (1) dynamically?
the problem is that $ {l.get (0)} must be inside "", that is :.
def gmail = ['sh','-c','grep "clientLogin=${l.get(0)}" file.txt' | grep gmail | wc -l ]
so that it looks like this:
def gmail = ['sh','-c','grep " clientLogin=a@yahoo.com " file.txt' | grep gmail | wc -l ]
but clientLogin=${l.get(0)} gives no result. I am not sure where I am going wrong.
Thank you for your suggestion, but it does not give a result, at least when I tried it.
file.txt has a lot of garbage and a template something like:
Into the domain clientLogin=a@yahoo.com exit on 12/01/2008 etc..
therefore i do
def ex = ['sh','-c','grep "domain clientLogin=$client" file.txt'| grep "something more" | wc -l]
that way I can bind grep the way I want and end up landing on the account I need.
I'm not sure if I can link greps if I use
def ex = ['grep', "$client", 'file.txt']
Thanks for your input.