I've found that pattern to be very useful when altering/sanitising MySQL backups.
# Set the engine of all tables in schema `foo` to TokuDB
sed -re '/^USE `foo`/,/^USE / s/^\) ENGINE=\S+/) ENGINE=TokuDB/'