title: How to filter strings using shell script
body: <p>I have a shell script called demo.sh that runs a command and store the output in a variable.</p>
  
  <p>Here is the script:</p>
  
  <pre><code>$#!/bin/sh
  a=`asterisk -rx "core show hint 101"`
  echo "${a}"
  </code></pre>
  
  <p>The output is:</p>
  
  <pre><code>101@hints           : SIP/101               State:Unavailable    Presence:not_set         Watchers  0
  </code></pre>
  
  <p>I only need to get the State section, in this case <strong>Unavailable</strong>. This state is not fixed, it changes. I need to get whatever is after <strong>State:</strong> but before <strong>Presence:</strong></p>
  
  <p>How can I do this?</p>