I want a count only when couple of value exist in each line of my source.

I have to get the count only if poc=4060 and loc=JPN ( basically I want to check both values exist then count the occurrences.)

disp0201.php?poc=4060&roc=1&ps=R&ooc=13&mjv=6&mov=5&rel=5&bod=155&oxi=2&omj=5&ozn=1&dav=20&cd=&daz=& drc=&mo=&sid=&lang=EN&loc=JPN

I have been trying like this
grep -c -E 'oc=70|pc=64150' samplelogs.log

tr -cs 'A-Za-z0-9=' '\n' < samplelogs.log | grep -c -E 'oc=70|pc=64150|rc=1'
but not seems to workout perfectly.

Help me on this..
Thanks
EM

If you just want to count the number of occurences try this:

$ awk '/poc=4060.*loc=JPN$/{++c}END{print c}' file

or

$ cat pattern.txt 
poc=4060.*loc=JPN

$ grep -c -f pattern.txt file
1 Like

Simply works great !!

Thanks,
EM