I want to count the number of times that a role is successfully deleted.  The problem is that one line of the log file will show that the script is about to delete the role:Prepare to remove role XThe next line will tell me if the delete is successful or not:Successful delete:Delete SuccessfulUnsuccessful delete:Failed to delete role X: error codeHow do I count the number of successful Role deletes?  I would just use the following grep:grep Delete Successful | wc -lHOWEVER, I am also deleting policies which is logged in the same manner as the roles are above.  IE:Prepare to delete policy XDelete SuccessfulORFailed to delete policy X: error codeAny way to search for Prepare to delete role on one line and then count the number of times the very next line says delete successful?
Count lines matching pattern and matching previous line
shell script;text processing;grep;wc