MySQL でタブ区切りのデータを出力
悩んだので。
何もしなくてもファイルにリダイレクトすればタブ区切りになる。
例えば
$ mysql -uroot -psecret -e "SHOW STATUS"
と打つと下記のように表整形された結果が出力される。
+------------------------------------------+-------------+ | Variable_name | Value | +------------------------------------------+-------------+ | Aborted_clients | 2 | | Aborted_connects | 8 | | Binlog_cache_disk_use | 0 | | Binlog_cache_use | 0 | | Binlog_stmt_cache_disk_use | 0 | | Binlog_stmt_cache_use | 0 | | Bytes_received | 117 | .........
これをファイルにリダイレクトすると単純にこのままファイルに出力されると思いきや、勝手にタブ区切りになってた。
$ mysql -uroot -psecret -e "SHOW STATUS" > status.log $ less status.log Variable_name Value Aborted_clients 2 Aborted_connects 8 Binlog_cache_disk_use 0 Binlog_cache_use 0 Binlog_stmt_cache_disk_use 0 Binlog_stmt_cache_use 0 Bytes_received 117
ほほう。