title: Reading lines in a file and avoiding lines with # with Bash
body: <p>I tried this:</p>
  
  <pre><code>file="myfile"
  while read -r line
  do
      [[ $line = \#* ]] &amp;&amp; continue
      "address=\$line\127.0.0.1"
  done &lt; "$file"
  </code></pre>
  
  <p>This code doesn't avoid the lines that begin with comments. Even if I don't have any comments, <code>dnsmasq</code> tells that there are errors.</p>
  
  <p>Its going to be a <code>dnsmasq</code> conf file, and it will read and insert domain names like so: <code>address=\mydomain.com\127.0.0.1</code>.</p>
  
  <hr>
  
  <h1>EDIT:1</h1>
  
  <p>Input file:</p>
  
  <pre><code>domain1.com
  domain2.com
  domain3.com
  #domain4.com
  domain5.com
  </code></pre>
  
  <p>Output should be:</p>
  
  <pre><code>address=/domain1.com/127.0.0.1
  address=/domain2.com/127.0.0.1
  address=/domain3.com/127.0.0.1
  address=/domain5.com/127.0.0.1
  </code></pre>
  
  <p>I will drop the script in <em>/etc/dnsmasq.d/</em> directory so that <a href="http://www.thekelleys.org.uk/dnsmasq/docs/dnsmasq.conf.example" rel="noreferrer">dnsmaq.conf</a> can  process it when <code>dnsmasq</code> is started.</p>