I have the below pattern in the logs file where a "Starts" is finished with a "Ends" in the next line. I am looking to print only if the next line pattern is not matched with a "Ends", i:e to print all the Starts which are not ended.
$ egrep AccountResource testlog.txt|egrep "Starts|Ends"
05:20:34.949 INFO c.b.h.r.rest.Account - AccountResource for account:12345 - Starts
05:20:45.863 INFO c.b.h.r.rest.Account - AccountResource () - Ends
05:20:46.274 INFO c.b.h.r.rest.Account - AccountResource for account:12345 - Starts
05:20:46.360 INFO c.b.h.r.rest.Account - AccountResource () - Ends
05:22:21.703 INFO c.b.h.r.rest.Account - AccountResource for account:12345 - Starts
05:22:22.680 INFO c.b.h.r.rest.Account - AccountResource for account:5678 - Starts
05:52:48.578 INFO c.b.h.r.rest.Account - AccountResource for account:5678 - Starts
05:52:50.673 INFO c.b.h.r.rest.Account - AccountResource () - Ends
05:52:50.937 INFO c.b.h.r.rest.Account - AccountResource for account:12345 - Starts
05:52:50.977 INFO c.b.h.r.rest.Account - AccountResource () - Ends
06:09:35.951 INFO c.b.h.r.rest.Account - AccountResource for account:5678 - Starts
06:09:36.409 INFO c.b.h.r.rest.Account - AccountResource () - Ends
06:09:36.690 INFO c.b.h.r.rest.Account - AccountResource for account:5678 - Starts
06:09:36.720 INFO c.b.h.r.rest.Account - AccountResource () - Ends
below is expected output
05:22:21.703 INFO c.b.h.r.rest.Account - AccountResource for account:12345 - Starts
05:22:22.680 INFO c.b.h.r.rest.Account - AccountResource for account:5678 - Starts