Reading uncommented line is almost a daily live for most Linux and Windows Sys Admin. Uncommented in .conf or .ini lines are the active or the lines that are currently in used for the loaded configuration. In Linux, it's quite straight forward to do it using grep. grep ^[^#] service_file.conf The above command uses regex, to search for lines in the .conf file that doesn't start with #. In regex ^ means the first character, but if it is inside the brackets it has other meaning. It negates whatever character that follows. So, the regex means search the first character that doesn't start with #. Technically, it's teling grep to search for uncommented lines. Yes, the above solution is for Linux. How can we do it in Windows? Well, it turns out to be almost the same but with a little twist of course since its a different operating system. So, here's how we can do it in Windows. findstr /b /v ^# file.txt Hopefully, it makes life easier and the above commands...
Make the world a better place by sharing knowledge, ideas and anything that you can give that comes from the heart.