madasafish
Technical User
Code:
gawk 'BEGIN {}
!/btvtracker/ { next }
{
split (substr ($12,50),a,"&");clickthru=a[1];etvchannel=a[2]
split (etvchannel,b,"=");chantype=b[1];channo=b[2]
x[channo","clickthru]++
}
END {
for (y in x) {
split (y,c,",");i=c[1];j=c[2]
vchanname=etvchannel
if (i=="101") { vchanname="BBC One"; }
if (i=="102") { vchanname="BBC Two" }
if (i=="203") { vchanname="ITV 1" }
if (i=="304") { vchanname="Channel 4" }
if (i=="405") { vchanname="Five" }
if (i=="506") { vchanname="BBC 3" }
if (i=="607") { vchanname="BBC 4 " }
if (i=="808") { vchanname="BBC ONE HD" }
# etc.......
#else { continue }
print i","vchanname","j","x[y]
}
}' ${FILE} | sort -n >> ${WEBDIR}/${SITE}.${REPDATE}.csv
The code above produces count of http hits from a large apache access log. It works but includes "i" numbers that I am not interested in which is why I am trying to use the "else" to filter out "i" numbers that I am not interested in. I have tried different permutations of placing the the brackets {} but cannot get the code to read the if statements as one block with the one following else. I have tried using "else if" as well but to no avail. Can someone please assist in providing the correct syntax?
For the more learned among you, I am not that keen on hard coding the TV names within the gawk program and would ideally like to have a seperate master file that held the names and the gawk program did a lookup to that file.
For example the master file would like this...
101,BBC One
102,BBC Two
203,ITV 1
304,Channel 4
405,Five
etc....
As always,
Thanks in advance
Madasafish