awk to count start and end keyword in a line

Hello fellow awkers and seders:

need to figure out a way to ensure a software deployment has completed by checking its trace file in which I can store the deployment results as follows:

echo $testvar
===== Summary - Deploy Result - Start ===== ===== Summary - Deploy Result - End ===== ===== Summary - Deploy Result - Start ===== ===== Summary - Deploy Result - End ===== ===== Summary - Deploy Result - Start ===== ===== Summary - Deploy Result - End ===== <and so forth>

logic as follows:

  • awk to look for keyword=Start; if found, then look for the keyword=End
  • when we have the sequence: Start|End|Start # this indicates deployment is in progress or stuck
  • every "Start" keyword has to pair with a subsequent "End" keyword

Would greatly appreciate it if anyone out there can help me crack this brain teaser :slight_smile:

Thanks.

Assuming your input exactly looks like the example you provided :

echo $test | awk -F"= =" 'NF%2{print "Deploymeny still in progress"}'
1 Like