awk/sed line parsing

I'm new to shell programming, but I think I learn best by following an example. I'm trying to cook up an awk/sed script, but I obviously lack the required syntax skills to achieve it. The output that I get from running my ksh script looks like this:

I need to search each numbered line for certain keywords. If I have no match, then simply continue with the rest of my script. If there are matches, then I want to be able to capture matched lines (to a temp file?) then report the matched lines as the command's output ('cat' temp file?) and exit my script. Appreciate any suggestions.

---------- Post updated at 06:38 AM ---------- Previous update was at 06:20 AM ----------

A bit more details of my framework:

( ksh myscript.ksh 2>&1 ) | tee -a $TEMP_LOG
            perl -ne "exit 1 if ( \
                /keyword1/ || \
                /keyword2/ || \
                /keyword3/ \
            );" $TEMP_LOG
            if [ $? -eq 1 ]
            then
                echo ""
                echo "Error while running myscript.sh!"
                EXITCODE=1
            else
                echo "Done running myscript.sh."
            fi
            rm -f $TEMP_LOG

So I basically want to be able to capture the keywords from the output of another command shown above and then error out along with reporting the lines with found keywords.

You should code the error handling and output generation directly inside myscript.ksh insead of creating another script that parse its output afterward.

Agreed. I will incorporate my error checking within myscript.sh. Meanwhile any suggestions on writing the awk code to filter out the keywords? In the output example above I want to be able to read between the CHANGED FILES: line and the next blank line. Then again between the NEW FILES: line and the next blank line, etc.

Give more clue about how does your initial input file look like (upload it if necessary), and how should the output look like.
.

This is the output of a tool command that I run :

The flow should be like this: I run an external tool command and I parse its output for certain keywords. If there's a match of keywords, then I want to spit out a message saying that the script cannot proceed any further due to the keyword matches and then spit out the matched lines. If there are no matches, however, then I want my external script to continue on.
I want to be able to parse the output like the one above and catch certain words, such as 'bar.txt' or 'foo/'. If I do have the matches, I'd like to say something like this:

Your request cannot proceed because you had the following critical changes:

... then list the captured matches as a whole line ...

Is "grep" not enough for your requirement?

I need to capture and list each line that contains a matching keyword. I think grep will handle only one case form the output, no?

from where you will get the matching keyword? or those static?

 
grep -e "pattern1|pattern2" will search for multiple patterns!

The keywords will be static and defined in the script. The output I've quoted earlier will be generated by some command which I call in my script and I want to be able to capture and parse the output for certain keywords. Then if I do have a keyword match, I want the script to quit and present the matched lines. I think grep only does one keyword at a time? I want my output to look like this (assuming there's a match for all instances of bar1.txt files and directories named 'foo'):

I did not get you fully!!!

Please post a sample input and output you are expecting along with the sample keywords.

Sorry for not being clear! Here's the sample run of an external command which I need to call within my script and its output:

When I run this command in my script, I want to be able to parse the output above for keywords which I also define in the script, such as "bar.txt", "foo/", etc. If there's a match, then I want my script to say something like this:

---------- Post updated at 03:48 AM ---------- Previous update was at 03:12 AM ----------

I tried to use this perl command as a parsing mechanism, but if I have a keyword that looks like "directory/file" then perl complains and I'm not sure how to escape the slash.

cat command_output.txt | perl -ne "exit 1 if ( /keyword1/ || /directory/keyword2/ || /XXXXXXXXXXXXXXXXX/ );" ; echo $?

---------- Post updated at 04:13 AM ---------- Previous update was at 03:48 AM ----------

Basically I want my script to look something like this:

external command | awk 'parse output for keywords'
if matches found
then
     print matched lines
     exit 1
else
     echo "no matches found"
fi