I'm trying to get this script working to count how many files of type .doc and .pdf are. But I keep getting syntax error on the last bracket for the for loop.
awk: ./parselog.awk:14: for ($7 in count)
awk: ./parselog.awk:14: ^ syntax error
Here's the awk script:
#!/usr/bin/awk -f
BEGIN {}
{
file = match($7, "/datasheets/")
doccheck = match(tolower($7), ".doc")
pdfcheck = match(tolower($7), ".pdf")
if( doccheck || pdfcheck )
{
count[$7]++
}
}
END{
for ($7 in count)
{
frequency = count[$7]
sub(/datasheets/,"",$7)
minusextension = $7
sub(/\....$/, "", minusextension)
print minusextension, $7, frequency
}
sort
}