私はgrepの-Aと-Bコマンドを使って私が探しているものをたくさん得ることができることを知っていますが、実際には私が望むものではありません。
httpd.confファイルを解析しようとしています。ドメイン名の検索。それからこのドメインのVirtualHostタグ間のすべてのエントリを表示します。。仮想ホストの例は次のとおりです。
ドメインを検索するには、次のコマンドを実行します。
less /usr/local/apache2/conf/httpd.conf |grep domain.tld
ただし、これは仮想ホスト全体を提供せず、ドメインを含む行のみを提供します。
<VirtualHost 192.168.1.10:80>
SSLEngine on
SSLCACertificateFile /usr/share/ssl/certs/ca-bundle.crt
SuexecUserGroup anzenketh wheel
ServerName anzenketh.net
ServerAlias www.anzenketh.net
ServerAdmin [email protected]
DocumentRoot /home/anzenketh/www/anzenketh.net
ScriptAlias /cgi-bin/ "/home/anzenketh/www/cgi-bin/"
<Directory /home/anzenketh/www/cgi-bin>
AllowOverride None
Options ExecCGI
Order allow,deny
Allow from all
</Directory>
CustomLog /var/log/httpd/anzenketh/anzenketh.net-access_log combined
ErrorLog /var/log/httpd/anzenketh/anzenketh.net-error_log
</VirtualHost>
ベストアンサー1
ここsed
2つの特定の文字列の間に含まれるすべての項目を取得する呼び出し。
sed -n '/<VirtualHost*/,/<\/VirtualHost>/p' httpd.conf
特定のドメインを検索するには、そのドメインを追加してください。
sed -n '/<VirtualHost 192.168.1.10:80>*/,/<\/VirtualHost>/p' httpd.conf