The mysql general log file looks like this...
110822 14:41:14 103700 Query SHOW FULL TABLES FROM `engine` LIKE 'PROBABLYNOT' 103700 Query SHOW FULL TABLES FROM `engine` LIKE 'PROBABLYNOT' 110822 15:01:14 103701 Query SHOW FULL TABLES FROM `dbname` LIKE 'PROBABLYNOT'
The thread ID 103701 can be found at the beginning or at number 3 position (after date-time) I am using the following command to find all the queries executed in a particular thread.
grep -w '103701' /var/log/mysql/general.log | cut -c 1-1000 | tail -10
This shows a lot of lines where 103701 number is mentioned. I am looking for this number only at first or third position. What should the correct grep statement for this?