How can I redirect output of mysql query with table border as separator? I try with this code :
mysql -u root -h localhost -D cronjob -e "select * from cron_list" > query.txt
What I expect is output like :
| id | datetime | recurrency | command |
| 1 | 2014-10-10 | daily | bash /media/data/daily.sh |
| 2 | 2014-10-09 | minutely | conky |
But when I use that code, it give me output like
id datetime recurrency command
1 2014-10-10 daily bash /media/data/daily.sh
2 2014-10-09 minutely conky
So, how can I redirect the output from terminal into file with separator like in terminal? Sorry for bad english
From man mysql
:
--table, -t
Display output in table format. This is the default for interactive use, but can be used to produce table output in batch mode.
Note -t
is the default behaviour, but not whenever you pipe to a file. That's why in that case you have to make it explicit.
Other interesting options, for other kind of outputs:
--silent, -s
Silent mode. Produce less output. This option can be given multiple times to produce less and less output.
This option results in nontabular output format and escaping of special characters. Escaping may be disabled by using raw mode; see the description for the --raw option.
--skip-column-names, -N
Do not write column names in results.
--html, -H
Produce HTML output.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With