I tried this:
file="myfile"
while read -r line
do
[[ $line = \#* ]] && continue
"address=\$line\127.0.0.1"
done < "$file"
This code doesn't avoid the lines that begin with comments. Even if I don't have any comments, dnsmasq
tells that there are errors.
Its going to be a dnsmasq
conf file, and it will read and insert domain names like so: address=\mydomain.com\127.0.0.1
.
EDIT:1
Input file:
domain1.com
domain2.com
domain3.com
#domain4.com
domain5.com
Output should be:
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
I will drop the script in /etc/dnsmasq.d/ directory so that dnsmaq.conf can process it when dnsmasq
is started.