I have two commands, build and deploy. Currently I run build manually, parse its output using my own eyes, and use a value I find in the output as an argument to deploy. The process looks something like:$ build==> amazon-ebs: amazon-ebs output will be in this color.... hundreds of lines of output ...==> Builds finished. The artifacts of successful builds are:--> amazon-ebs: AMIs were created:us-east-1: ami-19601070$ deploy ami-19601070... some more output ...(build is actually Packer, for the astute)I would like to tie these two steps together in a script. The rough outline would include the following:Run buildMake sure the exit status was 0 and that the output contained the string AMIs were created, otherwise abortExtract the AMI number (ami-19601070) from the outputRun deploy ami-19601070I'm trying to come up with the best way to connect everything together, ideally by using a shell script, but I'm stuck on how to grep the output for two separate patterns while, ideally, still streaming all stdout/stderr messages to the terminal as the commands run. I'm wondering if I should abandon the idea of doing this in a shell script and instead write a small Python script to do it.
How to display output of command while also parsing it?
shell script;grep;stdout;streaming