Grep in MySQL CLI interpretter

command-line-interface, mysql

Solution

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 ;)

Problem

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.

Original source