title: Shell regex to end of line
body: <p>I have a file like this little example:  </p>
  
  <pre><code># ...
  # mode=dev
  # ...
  </code></pre>
  
  <p>Somewhere in this file there is a "variable" within a comment. And i would like to get the value with regex in a Shell script.  </p>
  
  <p>My code so far:  </p>
  
  <pre><code>#!/bin/bash
  conf=$(&lt;"/etc/test.conf") # Get the file content
  regex='mode=(.*)$' # Set a regex
  if [[ $conf =~ $regex ]]; then # Search for the regex in the file
      # We found it, so ...
      echo "${BASH_REMATCH[1]}" # ... here is the value
  fi  
  </code></pre>
  
  <p>My big problem is, that it will not find the value :(<br>
  I tried a lot of different regex expressions and tested them with <a href="https://regex101.com/" rel="nofollow">https://regex101.com/</a> , but it seems, that the Shell regex interprator is different from <code>pcre</code> and <code>python</code>.  </p>
  
  <p>My best solution was to find the <code>mode=</code> and <strong>everything</strong> after it. So is there a way to get only the value? The start is easy ... find <code>mode=</code>. But how do I say the shell regex to get everything behind <code>mode=</code> <strong>until</strong> the next linebreak? and <strong>not beyond</strong> this linebreak?<br>
  Something with <code>\n</code> (unix linebreak) and <code>$</code> (end of string) did not work for me :(  </p>
  
  <p>Thanks for the help,<br>
  greetings</p>