awk pattern match and count unique in column

Hi all I have a need of searching some pattern in file by month and then count unique records

D11
G11
R11  -------> Pattern available in file
S11 
Jan
$1 to $5 column 

contains some records in which I want to find unique

for this purpose I have written script like below

awk '/Jan/ || /JAN/ || /January/&&!/D11/&&!/G11/&&!/R11/&&!/S11/&&!_[$1$2$3$4$5]++{n++}END{if(n-1==-1)p=0;else p=n-1;printf "%s%s%s","Uniques","\t:\t",p;printf "\n"}' n=0 $file >>Quality.log

Here my code is finding unique if I remove following part from code

'!/D11/&&!/G11/&&!/R11/&&!/S11/&&

this is working

awk '!_[$1$2$3$4$5]++{n++}END{if(n-1==-1)p=0;else p=n-1;printf  "%s%s%s","Uniques","\t:\t",p;printf "\n"}' n=0 $file >>Quality.log

actual problem is it's not searching all pattern

Is there any other simple way to search pattern by monthly and to write unique count of column 1 2 3 4 and 5 to log file

right now I am pasting same code 12 times by changing month field

Jan Feb Mar .....Dec

and appending to log file, but my hard luck it's not searching all pattern

I'm afraid it's not entirely clear what you want, programs which don't work for you are not nearly as illuminating as a good unabridged sample of the input data you have and the output data you want would be.

Thank corona

I am trying achieve following

assume file contains 12 months records which can easily be searched like this

awk '/Jan/{print}' file

lists all rows contains string Jan

and following code prints unique records considering column 1 to 5

awk '!_[$1$2$3$4$5]++' file

with small modification to above code following gives count of unique records

awk '!_[$1$2$3$4$5]++{n++}END{print n-1}' n=1 file

along with

Jan Feb ...Dec

string file contains some more strings.. which I mentioned in #1

whenever awk finds multiple patterns in $0, I want to store that $0 in array, and finally I want to count and write number of unique records available for that particular search

The same process I have to do 12 times {Jan .....Dec}

I am sorry to say, due to the restriction from department I am unable to attach sample data

if you understand the scenario please help me.

Hi there,
you would do well if you could explain the requirement in plain English. Those $0's, $1's, etc. only confuse a reader and make your intent difficult to understand.

You could post a sample by redacting the sensitive portions.

Give real data example on you like your output.