I want to be able to do something like this quickly:
I have a MySQL database table with visitors to my site. The columns are date, IP address, browser, URL, referer.
I want to do this:
- grab all the rows during a particular day
- delete all rows, making sure that in each 15-minute interval, no two rows have the same IP address
Is sed/awk suitable for these kinds of problems? Or would some scripting language such as Ruby be more appropriate?
I don’t quite “get” what sed/awk is actually for. Feel free to briefly explain that as well. Thank you!
Sed and Awk are meant as text processing tools. Therefore, they can help in situations where your data is presented in a nice text format (generally equivalent to human-readable).
An SQL database is generally stored in a binary format, for which these tools are not the best option. Even some formats that are human readable are better off with other tools (XML is probably the best example).
If you could export your database as a CSV (comma separated value spreadsheet), you might have a better chance to process it with these tools.
Otherwise, it’s way easier to use Perl/Python/Ruby with a suitable SQL module to access the data.
Hope this helps =)