title: How to extract words between two characters in linux?
body: <p>I have the following stored in a file named tmp.txt</p>
  
  <pre><code>user/config/jars/content-config-factory-3.2.0.0.jar
  </code></pre>
  
  <p>I need to store this word to a variable - </p>
  
  <pre><code>$variable=content-config-factory
  </code></pre>
  
  <p>I have written the following </p>
  
  <pre><code>  while read line
     do
      var=$(echo $line | awk 'BEGIN{FS="\/"; OFS=" "} {print $NF}' )
      var=$(echo $var | awk 'BEGIN{FS="-"; OFS=" "} {print $(1)}' )
      echo $var
    done &lt; tmp.txt
  </code></pre>
  
  <p>This returns the result "content" instead of "content-config-factory".</p>
  
  <p>Can anyone please tell me how to extract a word between two characters from a string efficiently.</p>