I needed to split a large file (in this case a mysql dump of all databases combined) into individual files each consisting of the SQL statements related to that DB. [Remember COBOL batch processing?]
Each section of the mysql database starts with:
-- Current Database: `mysql`
awk -F'`' '{if ($0 ~ /^-- Current Database:/) db=$2; print >> db"-20110301.sql"}' mysql-full-Tuesday.sql