I can find all non-matched lines of file with grep -v 'my_pattern' some_file
. Also i can print few strings before/after/around match with -A
, -B
or -C
options of grep. But i can't combine these two options to exclude lines with pattern and certain amount of lines near matched lines - grep shows entire file as result. For example, i have log with a lot of patterns like this:
25.02.2012 10:41:37 here goes memory state
25MiB free
16MiB allocated
max free block is 4MiB
I'd like to filter them. Of course, i can write custom perl/awk script, but is there more elegant way to do this?