title: Read each lines from an input file and print desired matched patterns
body: <p>I have the following details captured in a input.txt file from a command. My requirement is to match the patterns "Stopped|Aborted|isn't running" in any of the lines, need to print
  that line. And if the all are in "Running" state need to print a single message that "ALL ARE RUNNING".</p>
  
  <p>input.txt:</p>
  
  <pre><code>SVRSVC1 SVRSVC1 NAME    SVRSVC1 PID     Running
  SVRSVC2 SVRSVC2 NAME    SVRSVC2 PID     Running
  SVRSVC3 SVRSVC3 NAME    SVRSVC3 PID     Running
  SVRSVC4 SVRSVC4 NAME    SVRSVC4 PID     Running
  SVRSVC5 SVRSVC5 NAME    SVRSVC5 PID     isn't running
  SVRSVC6 SVRSVC6 NAME    SVRSVC6 PID     Running
  SVRSVC7 SVRSVC7 NAME    SVRSVC7 PID     Running
  SVRSVC8 SVRSVC8 NAME    SVRSVC8 PID     Aborted
  SVRSVC9 SVRSVC9 NAME    SVRSVC9 PID     Running
  SVRSVC10 SVRSVC10 NAME  SVRSVC10 PID    Running
  SVRSVC11 SVRSVC11 NAME  SVRSVC11 PID    Running
  SVRSVC12 SVRSVC12 NAME  SVRSVC12 PID    Stopped
  SVRSVC13 SVRSVC13 NAME  SVRSVC13 PID    Running
  SVRSVC14 SVRSVC14 NAME  SVRSVC14 PID    Running
  </code></pre>
  
  <p>I have the following code written but would like to know if this is a right approach. ? Please help.</p>
  
  <pre><code>#set -x
  RUNTIME=`date +%Y%m%d_%H%M%S`
  TOTAL_RUNSTAT=$(more input.txt | wc -l)
  while read -r line; do
  if [[ $line =~ Stopped|Aborted|"isn't running" ]]; then
   echo $line;
   elif [[ $line =~ Running ]]; then
    echo $line &gt;&gt; runstatuslog_$RUNTIME;
      if [[ `more runstatuslog_$RUNTIME | wc -l` =~ $TOTAL_RUNSTAT ]]; then
           echo "ALL SERVICES RUNNING";
      fi
  fi
  done &lt; input.txt
  </code></pre>
  
  <p>My desired output would be like this, If any matched pattern "Stopped|Aborted|isn't running" in the lines.</p>
  
  <pre><code>SVRSVC5 SVRSVC5 NAME    SVRSVC5 PID     isn't running
  SVRSVC8 SVRSVC8 NAME    SVRSVC8 PID     Aborted
  SVRSVC12 SVRSVC12 NAME  SVRSVC12 PID    Stopped
  </code></pre>
  
  <p>If no matched pattern in the lines &amp; all are "Running" then print "ALL ARE RUNNING"</p>
  
  <p>Thanks in advance,</p>