Ok, in a file like this I need to find all the occurrences of where the 'marker' pattern does not come after or before another 'marker' pattern:

marker 1
marker 2

marker 3

marker 4
marker 5
marker 6

So the multiline expression should only match on 'marker 3'

sed -n -e '/^.*marker.*$/I!{N;/^.*marker.*$/I{N;/^.*marker.*$/I!{p;};};};' testfile

but the script will not print the match.

GNU sed version 4.1.5