List:General Discussion« Previous MessageNext Message »
From:Dan Nelson Date:October 17 2011 2:57am
Subject:Re: How to enable tabular output when reading command from file?
View as plain text  
In the last episode (Oct 16), Peng Yu said:
> 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.

Add the --table option to your mysql commandline.  In batch mode, mysql
generates tab-delimited output which is easier to process.

       o   --table, -t

           Display output in table format. This is the default for interactive
           use, but can be used to produce table output in batch mode.

-- 
	Dan Nelson
	dnelson@stripped
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