Double grep help

Hello,

If I run the following to search the MySQL slow query log

grep -A 6 '# Time:' grep 'Query_time' slow.log | cut -c 1-150

And I get the following:

Qery_time: 41.976738  Lock_time: 0.000179  Rows_sent: 0  Rows_examined: 5579456  Rows_affected: 1639419
slow.log-# Bytes_sent: 59
slow.log-SET timestamp=1559638114;
slow.log-INSERT INTO wf11127ebf9250c51394951b8ec4b17ce

Is it possible to only return if the nth line has insert into?

Thanks.

Your question is not clear. Are you just looking to print ‘INSET’ line?

grep -A 6 '# Time:' | grep 'Query_time' slow.log | cut -c 1-150 | grep 'INSERT INTO'

Linux sysadmin blog - Linux/Unix Howtos and Tutorials - Linux bash shell scripting wiki