I am trying to search a log file for logged activities that did not complete.  For example, I log a Starting activity for ID 1234... and if successful, the next line will be Activity 1234 Completed.I'm trying to get the Starting... lines that are NOT followed by their corresponding Completed lines.Example Log FileStarting activity for ID 1234ID 1234 completed successfullyStarting activity for ID 3423ID 3423 completed successfullyStarting activity for ID 9876ID 9876 completed successfullyStarting activity for ID 99889ID 99889 completed successfullyStarting activity for ID 10011ID 10011 completed successfullyStarting activity for ID 33367Starting activity for ID 936819ID 936819 completed successfullyIn this example, I would be looking for the output to be:Starting activity for ID 33367...because it's not followed by a completed line.I've tried doing this with grep and awk, but have not had much success.  I'm assuming it can be done with one of those tools, but my grep and awk chops are not advanced.Looking for a quick and reliable grep or awk pattern to give the results I need here.
Print a line only if the next line does NOT contain a particular match
grep;sed;awk
Here is an awk alternative:awk '  /^Starting/ { I[$5] = $0                  }  /^ID/       { delete I[$2]                }  END         { for (key in I) print I[key] }' infileOutput:Starting activity for ID 33367The I associative array keeps track of what ids have been seen.