List:General Discussion« Previous MessageNext Message »
From:Peng Yu Date:October 16 2011 4:36pm
Subject:How to enable tabular output when reading command from file?
View as plain text  
Hi,

~/linux/test/mysql/mysql/SELECT$ ./main.sh
name	date	type	remark
Fluffy	1995-05-15	litter	4 kittens, 3 female, 1 male
Buffy	1993-06-23	litter	5 puppies, 2 female, 3 male
Buffy	1994-06-19	litter	3 puppies, 3 female
Chirpy	1999-03-21	vet	needed beak straightened
Slim	1997-08-03	vet	broken rib
Bowser	1991-10-12	kennel	
Fang	1991-10-12	kennel	
Fang	1998-08-28	birthday	Gave him a new chew toy
Claws	1998-03-17	birthday	Gave him a new flea collar
Whistler	1998-12-09	birthday	First birthday
~/linux/test/mysql/mysql/SELECT$ cat main.sh
^[#!/usr/bin/env bash

mysql -hlocalhost -uuser < main.sql

~/linux/test/mysql/mysql/SELECT$ cat main.sql
use test
select * from event;

===============

The above command doesn't print as formatted in the following. I'm
wondering what options I should use to produce a result similar to the
following.


=====================
mysql> select * from event
    -> ;
+----------+------------+----------+-----------------------------+
| name     | date       | type     | remark                      |
+----------+------------+----------+-----------------------------+
| Fluffy   | 1995-05-15 | litter   | 4 kittens, 3 female, 1 male |
| Buffy    | 1993-06-23 | litter   | 5 puppies, 2 female, 3 male |
| Buffy    | 1994-06-19 | litter   | 3 puppies, 3 female         |
| Chirpy   | 1999-03-21 | vet      | needed beak straightened    |
| Slim     | 1997-08-03 | vet      | broken rib                  |
| Bowser   | 1991-10-12 | kennel   |                             |
| Fang     | 1991-10-12 | kennel   |                             |
| Fang     | 1998-08-28 | birthday | Gave him a new chew toy     |
| Claws    | 1998-03-17 | birthday | Gave him a new flea collar  |
| Whistler | 1998-12-09 | birthday | First birthday              |
+----------+------------+----------+-----------------------------+
10 rows in set (0.03 sec)


-- 
Regards,
Peng
Thread
How to enable tabular output when reading command from file?Peng Yu16 Oct
  • Re: How to enable tabular output when reading command from file?Dan Nelson17 Oct