title: Parsing Command Output in Bash Script
body: <p>I want to run a command that gives the following output and parse it:</p>
  
  <pre><code>[VDB VIEW]
  [VDB] vhctest
          [BACKEND] domain.computername: ENABLED:RW:CONSISTENT
          [BACKEND] domain.computername: ENABLED:RW:CONSISTENT
          ...
  </code></pre>
  
  <p>I'm only interested in some key works, such as 'ENABLED' etc. I can't search just for ENABLED as I need to parse each line at a time.</p>
  
  <p>This is my first script, and I want to know if anyone can help me?</p>
  
  <p>EDIT:
  I now have:</p>
  
  <pre><code>cmdout=`mycommand`
  
  while read -r line
  do
     #check for key words in $line
  done &lt; $cmdout
  </code></pre>
  
  <p>I thought this did what I wanted but it always seems to output the following right before the command output.</p>
  
  <blockquote>
    <p>./myscript.sh: 29: cannot open ... : No such file</p>
  </blockquote>
  
  <p>I don't want to write to a file to have to achieve this.</p>
  
  <p>Here is the psudo code:</p>
  
  <pre><code>cmdout=`mycommand`
  
  loop each line in $cmdout
     if line contains $1
         if line contains $2
              output 1
         else
              output 0
  </code></pre>