I have multiple log files and I need to count the number of occurrences of certain patterns in all those files.
#!/usr/bin/awk
match($0,/New connection from user \[[a-z_]*\] for company \[([a-z_]*)\]/, a)
{instance[a[1]]++}
END {
for(i in instance)
print i":"instance[i]
}
I am running this script like this:
awk -f script *
But it looks like count is not correct. Is my above approach correct to handle multiple files?