On my machine the command mysql -e "show databases" generates the following output:
$ mysql -e "show databases
+--------------------+
| Database |
+--------------------+
| information_schema |
| database1 |
| database2 |
| mysql |
| performance_schema |
| sys |
+--------------------+
However, when I pipe this to any command (or redirect to file), the formatting vanishes:
$ mysql -e "show databases" | cat
Database
information_schema
database1
database2
mysql
performance_schema
sys
I thought that the formatting may come through stderr, but this does not seem to be the case:
$ mysql -e "show databases" 2>/dev/null
+--------------------+
| Database |
+--------------------+
| information_schema |
| database1 |
| database2 |
| mysql |
| performance_schema |
| sys |
+--------------------+
Why do the formatting characters not go through the pipe? Can I change this behaviour?