Skip to content

Instantly share code, notes, and snippets.

@tkuchiki
Last active January 15, 2016 10:20
Show Gist options
  • Save tkuchiki/e0dc9e5db0ef6ab48136 to your computer and use it in GitHub Desktop.
Save tkuchiki/e0dc9e5db0ef6ab48136 to your computer and use it in GitHub Desktop.
grep でマッチした行と、その次のN行を除外する
$ grep -P -A 3 'Lock_time: (?!0)' slowquery.log
# Query_time: 0.017416  Lock_time: 1.000000 Rows_sent: 0  Rows_examined: 0
use test;
SET timestamp=1452839731;
commit;
--
# Query_time: 0.017416  Lock_time: 2.000000 Rows_sent: 0  Rows_examined: 0
use test;
SET timestamp=1452839734;
commit;
# Query_time: 0.017416 Lock_time: 1.000000 Rows_sent: 0 Rows_examined: 0
use test;
SET timestamp=1452839731;
commit;
# Query_time: 0.017416 Lock_time: 0.000000 Rows_sent: 0 Rows_examined: 0
use test;
SET timestamp=1452839732;
commit;
# Query_time: 0.017416 Lock_time: 0.000000 Rows_sent: 0 Rows_examined: 0
use test;
SET timestamp=1452839733;
commit;
# Query_time: 0.017416 Lock_time: 2.000000 Rows_sent: 0 Rows_examined: 0
use test;
SET timestamp=1452839734;
commit;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment