Below is my sample data file.
$ cat test.conf
Options -Indexes -FollowSymLinks -Includes -ExecCGI
#Options -Indexes -FollowSymLinks -Includes -ExecCGI
<Directory "/web/htdocs">
Options -Indexes -FollowSymLinks -Includes -ExecCGI
<Directory "/web/htdocs"> Options -Indexes -FollowSymLinks -Includes -ExecCGI
RewriteOptions -tester
Options -Indexes -FollowSymLinks -Includes -ExecCGI
I wish to get all the entries (only single lines) using regex that
Begins(start) with the string "Options"
followed by an of these strings "Indexes" "FollowSymLinks" "Includes" "ExecCGI"
I tried the below regex but the problem is that it is yeilding the output "#Options -Indexes -FollowSymLinks -Includes -ExecCGI"
where the line begins with a hash '#' as well as the line "<Directory "/web/htdocs"> Options -Indexes -FollowSymLinks -Includes -ExecCGI"
which do not begin with Options on a new line.
Current Output:
$ grep -E '^[^\n|#]*[^!Rewrite]Options.*|Indexes|FollowSymLinks|Includes|ExecCGI$' test.conf
Options -Indexes -FollowSymLinks -Includes -ExecCGI
#Options -Indexes -FollowSymLinks -Includes -ExecCGI
Options -Indexes -FollowSymLinks -Includes -ExecCGI
<Directory "/web/htdocs"> Options -Indexes -FollowSymLinks -Includes -ExecCGI
Options -Indexes -FollowSymLinks -Includes -ExecCGI
Desired Output:
Options -Indexes -FollowSymLinks -Includes -ExecCGI
Options -Indexes -FollowSymLinks -Includes -ExecCGI
Options -Indexes -FollowSymLinks -Includes -ExecCGI
I'm not looking for grep -v
as a solution but a regex negation instead.
Can you please suggest a regex to meet my requirement ?