I want to get a value form show variables query using the shell script. This is the command i used.
data=$(mysql -u root -proot -t -e "show variables where variable_name = 'datadir';" -B --skip-column-names)
Out put result is,
+---------------+-----------------+
| Variable_name | Value |
+---------------+-----------------+
| datadir | /var/lib/mysql/ |
+---------------+-----------------+
So i just want to get the value.
/var/lib/mysql/
This is the Script which i try,
data=$(mysql -u root -proot -t -e "show variables where variable_name = 'datadir';" -B --skip-column-names)
data2=$(echo $data | tr "+---------+-----------------+" "\n")
data3=$(echo $data2 | tr "|" "\n")
data4=$(echo $data3 | tr "datadir " "\n")
echo $data4
its returning "/v /l b/mysql/".
-toption. It's overriding-B, so you get the borders.