# Secure (SSL/TLS) connections
#Include conf/extra/httpd-ssl.conf
#Include conf/extra/httpd-ssl.conf
# Include conf/extra/httpd-ssl.conf
#Include conf/extra/httpd-ssl.conf
#
# Note: The following must must be present to support
#
This should not match anything but if you try my sample text and regex in regex101.com or any online regex checker it matching the first entry which has new line as a "newline".
#Include conf/extra/httpd-ssl.conf
<MATCHES IF ABOVE IS A NEWLINE>
How can we make sure that the first visible charecter of a line should be string "Include" and preceeded by string " "httpd-ssl.conf""
Don't worry, your overcomplicated regex doesn't match anything reasonable in your file, if that is what you're after (not clear from your spec). Even uncommented lines with # removed (which I added to your sample file) aren't matched:
You could have tried yourself on your "Oracle Linux system", also questioning your online regex tester.
See the detailed, step by step analysis of your regex (culprit seem to be items 3 and 4):
^[[:blank:]]*[^[:blank:]#;].+Include.*httpd-ssl.conf
^ # start of line
[[:blank:]]* # any number of space, TAB, newline
[^[:blank:]#;] # ONE char non-blank, non-#, non-;
.+ # ONE or many chars, whichever
Include # string constant "Include"
.* # any number of any char
httpd-ssl.conf # string constant
530 #Include conf/extra/httpd-ssl.conf
531
532 Include conf/extra/httpd-ssl.conf
533 # Include conf/extra/httpd-ssl.conf
534 Include conf/extra/httpd-ssl.conf
535 # Include conf/extra/httpd-ssl.conf
536 #Include conf/extra/httpd-ssl.conf
537 #
Note: the left numbering(5**) is only the line number populated using set nu of vi editor and not the actual file content.
The explanation that you gave for my regex should atleast match line number "532" but it does not.
Line number "532" passes all of the below but the command still fails to yeild any matches(output):
^ # start of line
[[:blank:]]* # any number of space, TAB, newline
[^[:blank:]#;] # ONE char non-blank, non-#, non-;
.+ # ONE or many chars, whichever
Include # string constant "Include"
.* # any number of any char
httpd-ssl.conf # string constant
Can you please explain why ?
Nevertheless the below regex works for me and gets me unhashed lines starting with "Include" followed by "httpd-ssl.conf"
# grep -E "^[[:blank:]]*[^[:blank:]#;].+Include.*httpd-ssl.conf" /tmp/httpd.conf
Fails for the sample data shared in this post for reasons I wish to know
# grep -E "^[^#]*Include.+httpd-ssl.conf" /tmp/httpd.conf
Include conf/extra/httpd-ssl.conf
Include conf/extra/httpd-ssl.conf
Passes.