awk has the ability to do arrays. Indices for arrays in awk are actually characters. So you can define an array like:
This should simultaneously allocate and increment the counter array if it doesn't already exist. I'm not sure if awk initializes the value to zero and I don't have the time right now to check. It it doesn't, then you need to initialize everything in a BEGIN block. You'll have to put your awk code in a file since it will take a few lines to do what you want to do. But here's an example (make a file called "myprog.awk"):
Code:
# This is the BEGIN block that initializes stuff
BEGIN{
Counter[50005]=0;
}
# Here is your conditional statement
if ( ($10==50005) && ($22==128) && ( $12~/^61/) || ($12~/^62/) && length($12) <= 8)
{
Counter[50005]+=1
}
# This is the END block that will output the results
END{
for (i in Counter)
{
printf("%10d--------%10d",i,Counter[i]
}
You could then run this file with:
Code:
awk -f mycode.awk prm942_$d.txt
That should do it....