PROBLEM
I want to specifically use AWK (GAWK, MAWK, whatever) in an AWK script to sum up the values in field 9 for every record that contains "runner__.jpx" (the underscores are placeholders for two digits 0-9) in field 6 and "good" in FIELD 7.
SAMPLE FILE
Feb 14 11:33:16 ringer a[2388]: runner01.jpx good aa 3
Feb 14 11:33:32 ringer a[2388]: runner24.jpx good xx 1
Feb 14 11:33:39 ringer a[1894]: jogger02.jpx good aa 5
Feb 14 11:33:45 ringer a[2388]: runner99.jpx stop cc 1
ATTEMPT
How could I do this? I tried using an if statement, like:
BEGIN {
sum = 0
}
{
if (($6 == "runner"[0-9][0-9]".jpx") && ($7 == "good"))
sum += $9
}
END {
printf sum
}
Is there way to do this by matching strings in fields using if statements? Am I allowed to use regular expressions within the if statement? What is an alternative method to do this? Thanks.