title: How can I assign the match of my regular expression to a variable?
body: <p>I have a text file with various entries in it. Each entry is ended with line containing all asterisks.</p>
  
  <p>I'd like to use shell commands to parse this file and assign each entry to a variable. How can I do this?</p>
  
  <p>Here's an example input file:</p>
  
  <pre>
  ***********
  Field1
  ***********
  Lorem ipsum
  Data to match
  ***********
  More data
  Still more data
  ***********
  </pre>
  
  <p>Here is what my solution looks like so far:</p>
  
  <pre><code>#!/bin/bash
  for error in `python example.py | sed -n '/.*/,/^\**$/p'`
  do
      echo -e $error
      echo -e "\n"
  done
  </code></pre>
  
  <p>However, this just assigns each word in the matched text to $error, rather than a whole block.</p>