我正在bash中尝试以下mysql命令
#!/bin/bash
k=`echo SHOW COLUMNS FROM dsac000 \; | mysql -ulogin -ppw -A db`
echo $k
但我知道
Field Type Null Key Default Extra ID bigint(20) NO NULL DSAC0SEQU decimal(11,0) NO NULL DSAC0STAC varchar(3) YES NULL DSAC0N010 bigint(20) YES NULL DSAC0N011 varchar(50) YES NULL DSAC0N012 varchar(15) YES NULL DSAC0N013 int(11) YES NULL DSAC0N014 varchar(30) YES NULL DSAC0N015 varchar(26) YES NULL DSAC0A00N varchar(40) YES NULL DSAC0A00P varchar(60) YES NULL DSAC0DNAI date YES NULL DSAC0STAT varchar(3) YES NULL ....
通常我必须得到如下布局:
http://www.c-sharpcorner.com/UploadFile/65fc13/some-help-and-show-commands-in-mysql/Images/img-4.gif
我试着加——桌子
#!/bin/bash
k=`echo SHOW COLUMNS FROM dsac000 \; | mysql -ulogin -ppw --table -A db`
echo $k
但产出仍保持在一条线上
+-------------+---------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +-------------+---------------+------+-----+---------+----------------+ | ID | bigint(20) | NO | | NULL | | | DSAC0SEQU | decimal(11,0) | NO | | NULL | | | DSAC0STAC | varchar(3) | YES | | NULL | | | DSAC0N010 | bigint(20) | YES | | NULL | | | DSAC0N011 | varchar(50) | YES | | NULL | | | DSAC0N012 | varchar(15) | YES | | NULL | | | DSAC0N013 | int(11
有人能帮我解决这个问题吗?
最佳答案
echo "$k"
注意
"
周围的$k
见this question