-B NUM, --before-context=NUM
Print NUM lines of leading context before matching lines. Places a line containing -- between contiguous groups of matches.
here i see everyone have used a same keyword "pending" for separation.
If we want to use multiple keywords then how will be the command.?
for example if there is one more entry in table like
Ron
Status: Form submission is complete but application fees are not submitted
How we can separate this line also by using a single querry.?
awk '{getline x; $0=$0 "\t" x;} !/success/' file
Shyne Status: Form submission pending.
Ron Status: Form submission is complete but application fees are not submitted
Rich Status: Form submission pending.
cat file
Jhon
Status: Form successfully submitted
Maria
Status:Form successfully submitted
Shyne
Status: Form submission pending.
Liken
Status:Form successfully submitted
David
Status:Form successfully submitted
Rich
Status: Form submission pending.
Ron
Status: Form submission is complete but application fees are not submitted
awk '/pending|application/{if(a && a !~ /pending|application/) print a; print}{a=$0}' file
Shyne
Status: Form submission pending.
Rich
Status: Form submission pending.
Ron
Status: Form submission is complete but application fees are not submitted
I did not test them them, but unless your form blocks users who include "pending", "application", or "success" as substrings, then, in my opinion, every suggestion so far is unsuitable.
Even if you consider such an event a remote possibility, if this is a critical task, such unlikely scenarios should be properly handled.
It seems that Scrutinizer's sed approach can be easily fortified using \n to segregate the user name from the status text.