awk

awk

Examples

with mysql

mysql -u myuser -p mytable -e "show table status where Engine='MyISAM';" | awk  'NR>1 {print "ALTER TABLE "$1" ENGINE = InnoDB;"}'

Where:
NR: The total number of input records seen so far.
So, NR>1 causes awk to skip the first line (where there are the unnecessary output headers).

The above script works if fields are separated by spaces, but if you use mysql to select a comment or text field which includes some spaces, the script will fail.

Syndicate content