Results 1 to 2 of 2
Enjoy an ad free experience by logging in. Not a member yet? Register.
- Join Date
- Sep 2010
find a pattern not followed by another pattern
I have a big file (over a thousand records) e.g.:
store id: A
store id: B
store id: C
store id: D
store id: E
And for instance in the above example "store id: C" was not followed by the "Processing..." pattern, so I konw "store id: C" was not processed. Is there a one liner that I can use (preferably grep since I am most familiar with) to extract "store id: C" (or stores that are not followed by the "Processing..." pattern?
Any thoughts would be highly appreciated.
Not with grep. grep only supports POSIX regular expressions and extended regular expressions.
What you are looking for is called a negative lookahead assertion. It is basically a zero-length match that asserts that something does not exist. For instance (using Perl syntax):
Perl and Ruby both support these, as do Vim regular expressions. I'm sure that they are supported elsewhere as well.