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 comes in handy the next time you read .conf or .ini for uncommented lines or config.
Here's a sample image for Windows.
Till next time..Ciao!
Prayer brings miracles. All you need is a trusting heart and surrender your needs in God's hands.
Pray and surrender to God, and let the miracles unfold in your life according to God's will.
Jermiah 29:11 For I know the plans I have for you,” declares the Lord, “plans to prosper you and not to harm you, plans to give you hope and a future.
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 comes in handy the next time you read .conf or .ini for uncommented lines or config.
Here's a sample image for Windows.
Till next time..Ciao!
Prayer brings miracles. All you need is a trusting heart and surrender your needs in God's hands.
Pray and surrender to God, and let the miracles unfold in your life according to God's will.
Jermiah 29:11 For I know the plans I have for you,” declares the Lord, “plans to prosper you and not to harm you, plans to give you hope and a future.
Comments
Post a Comment