I'm not sure what's going on here with the line art output by /usr/bin/mysql here.
The problem: I'm unable to redirect the line art (used in creating the table columns) to a file!
First, I do this on my terminal.
[sd@host:~/tmp]
$ mysql -usd sd -e 'select * from loan;'
+---------+--------------+--------+
| loan_no | branch_name | amount |
+---------+--------------+--------+
| L-11 | Round Hill | 900 |
| L-14 | Downtown | 1500 |
| L-15 | Perryridge | 1500 |
| L-16 | Perryridge | 1300 |
| L-17 | Downtown | 1000 |
| L-23 | Redwood | 2000 |
| L-93 | Mianus | 500 |
+---------+--------------+--------+
Now, I want this whole blessed thing printed above captured, so I redirect stdout and stderr to the file 'out', like so:
[sd@host:~/tmp]
$ mysql -usd sd -e 'select * from loan;' >out 2>&1
As you can see below, the line art is completely missing!
[sd@host:~/tmp]
$ cat out
loan_no branch_name amount
L-11 Round Hill 900
L-14 Downtown 1500
L-15 Perryridge 1500
L-16 Perryridge 1300
L-17 Downtown 1000
L-23 Redwood 2000
L-93 Mianus 500
More proof that the line art is REALLY missing! (The -T option prints tabs, if any.)
[sd@host:~/tmp]
$ cat -T out
loan_no^Ibranch_name^Iamount
L-11^IRound Hill^I900
L-14^IDowntown^I1500
L-15^IPerryridge^I1500
L-16^IPerryridge^I1300
L-17^IDowntown^I1000
L-23^IRedwood^I2000
L-93^IMianus^I500
So, my question is, how the heck does mysql know who -- whether a terminal or a text file -- is sucking its output from 'its rear end' :-) ?