Created
May 30, 2018 18:38
-
-
Save jdeathe/7e2d236b2d13e05cac2c349eac4196a0 to your computer and use it in GitHub Desktop.
Revisions
-
jdeathe revised this gist
May 30, 2018 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,4 +1,4 @@ The output of `apachectl -S` is really useful but it's not easy to parse in a script. To make it easier to find the configuration file for a given NameVirtualHost host the following BASH one liner returns lines of output that can be easily parsed. ``` # apachectl -S 2>&1 \ -
jdeathe created this gist
May 30, 2018 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,11 @@ The output of `apachectl -S` is really useful but it's not easy to parse in a script. To make it easier to find the configuration file for a given host the following BASH one liner returns lines of output that can be easily parsed. ``` # apachectl -S 2>&1 \ | sed -rn -e '/NameVirtualHost$/,$ { /NameVirtualHost$/d; $ d; p; }' \ | sed -rn -e 's/^.*(port ([0-9]+) namevhost|alias) ([^ ]*)( )?(\((.*):[0-9]+\)|$)/\2 \6\n\3/p' \ | sed -r -e '/^$/d' -e 's/(.*\.conf$)/\n\1/g' \ | awk -vRS='' '$1=$1' \ | sort -n \ | uniq ```