echo '送りたいコマンドやSQL' | mysql オプション ...
例. データベースnewsで、"show table status"の必要な項目だけ確認したい場合は以下のようにできます。
$ echo 'show table status' | mysql -u root -D news | awk '{print $1,$2,$5}'
Name Engine Rows
carrier InnoDB 9
category InnoDB 6
item InnoDB 7916
site InnoDB 14
site_access_log InnoDB 62135
Name Engine Rows
carrier InnoDB 9
category InnoDB 6
item InnoDB 7916
site InnoDB 14
site_access_log InnoDB 62135
また、これを使ってSQLを実行するシェルスクリプトを作ればいろいろと便利です。
これらのまとめ
・シェルからMySQLのコマンドやSQLを実行
・シェルスクリプトでMySQLのコマンドやSQLを実行