Malcolm: SQL for the command line: "show"
Posted Mar 24, 2009 21:35 UTC (Tue) by skx
In reply to: Malcolm: SQL for the command line: "show"
Parent article: Malcolm: SQL for the command line: "show"
It is funny how people get hooked on using SQL for querying logfiles. Last year or so I wrote asql which I use for producing adhoc statistics form Apache logfiles.
Simple usage is:
asql v1.2 - type 'help' for help.
asql> load /home/www/www.steve.org.uk/logs/access.log
asql> SELECT source,SUM(size) AS Number FROM logs GROUP BY source ORDER BY Number DESC, source LIMIT 0,10;
Finding the top ten referers becomes:
asql> SELECT referer,COUNT(referer) AS number from logs WHERE referer NOT LIKE '%steve.org.uk%' GROUP BY referer ORDER BY number DESC,referer LIMIT 0,10;
Although SQL is often not the most natural way to query things I found it very useful and natural in this context.
to post comments)