title: Grab preceding and trailing characters
body: <p>When writing, I annotate my text inline with notes to myself, for instance indicating where I need to expand on an idea. These notes are set off from the rest of the text by brackets, and start with 'tk' e.g., </p>
  
  <blockquote>
    <p>This is some text [tk explain why the text is important]. This is some context.</p>
  </blockquote>
  
  <p>I would like to write a simple bash script that takes my text and returns all of my notes, with some preceding and trailing characters. For instance, running the command on the above text would ideally return something like</p>
  
  <blockquote>
    <p>some text [tk explain why the text is important]. This is </p>
  </blockquote>
  
  <p>Right now, I am grabbing the text from the clipboard and running it through grep, but that returns the entire line rather than a set number of proceeding and trailing characters. That is,</p>
  
  <pre><code>pbpaste | grep 'tk'
  </code></pre>
  
  <p>returns the entire line.</p>
  
  <p>If I could at least get pointed to the appropriate set of commands, I can MacGyver myself a solution.</p>