Listing some useful sed / awk liners to use with MySQL. I use these on occasion.
sed, awk & grep have many overlapping features. Some simple tasks can be performed by either. For example, stripping empty lines can be performed by either:
grep '.' awk '/./' sed '/./!d' grep -v '^$' awk '!/^$/' sed '/^$/d'
It's a matter of taste & convention which tool and variation to use. So for any script I suggest, there may be many variations, possibly cleaner, shorter; feel free to comment.
The output of mysqldump is in particular useful when one wishes to make transformation on data or metadata.
- Convert MyISAM tables to InnoDB:
mysqldump | sed -e 's/^) ENGINE=MyISAM/) …[Read more]