Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Grep in MySQL CLI interpretter

Is there any way to grep the output of the MySQL interpretter (CentOS 5.x)? For instance, I know that I need a table with "user" in the table name. Ideally, I would love something like this:

DESCRIBE TABLES; | grep "user"

I know that I can exit MySQL and then do it in bash:

mysql -u me -p "USE someTable; DESCRIBE TABLES;" | grep "user"

But I would prefer to stay in MySQL. Thanks.

like image 934
dotancohen Avatar asked Apr 16 '12 15:04

dotancohen


People also ask

What is MySQL command line?

mysql is a simple SQL shell with input line editing capabilities. It supports interactive and noninteractive use. When used interactively, query results are presented in an ASCII-table format. When used noninteractively (for example, as a filter), the result is presented in tab-separated format.

What is MySQL command line client Unicode?

The Windows installer creates an item in the MySQL menu named MySQL command line client - Unicode . This item invokes the mysql client with properties set to communicate through the console to the MySQL server using Unicode.


1 Answers

Give this a try!

mysql> pager grep user
PAGER set to 'grep user'
mysql> USE someTable;
mysql> DESCRIBE TABLES;

I've just tried it with Mysql v5.0.83, and it does what you would think ;)

like image 183
Alister Bulman Avatar answered Oct 02 '22 11:10

Alister Bulman