Parsing MySQL output in Bash -
How can I redirect the output of the mysql query as a table sercer? I try with this code:
mysql -u root -h localhost -d cronjob -e "Select * from cron_list"> Query.txt I hope that such an output is:
| id | day-time | recursive | command | | 1 | 2014-10-10 | daily | Bash / Media / Data / Daily | sh | | | | | | | | | | | | | | | 2014-10-09 | Minute | Concrete | But when I use that code, I output to
id datetime recurrency command 1 2014-10-10 Daily Bash / Media / Data / Daily.sh 2 2014-10-09 linear conveyor So, the term How can I redirect output to a file with a separator like a terminal, like the terminal? Sorry for the bad english
From man mysql :
- Table, -T
Display the output in the 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 behavior, but whenever you have a pipe in a file that is why in that case you have to clarify it.
Other interesting options for other types of output:
- Quiet, - S
Silence Mode of low production This option can be given multiple times for production of low and low output.
This option is used to avoid non-tabular output formats and to avoid special characters. Avoiding using raw mode can be disabled; ---- See details for options.
- Chip-column-name , -N
Write column names in the results.
- html, -h
Prepare the HTML output.
Comments
Post a Comment