apachectl でドメイン名を取得する

apachectl -S でドメイン名が出るのでそれを重複なしで出力する

apachectl -S | egrep "(^.*\*:[0-9]+(\s| | |\t)*)|^(([1-9]?[0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([1-9]?[0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])" | sed -E 's/(^.*\*:[0-9]+(\s| | |\t)*) | (([1-9]?[0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([1-9]?[0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]):[0-9]*(\s| | |\t)*//g' | sed -e "/^.*example.com.*$/d" | sed -E "s/\(.*\)//g" | sed -E "s/(\s| | |\t)//g" | grep -E '(\.com|\.net|\.cc|\.co\.jp|\.or\.jp|\.jp|\.org|\.info|\.biz|\.me|\.mobi|\.vc|\.tv|\.bz)$'

意味

IP番号ポートもしくはポートで指定してあるドメイン名の行を grep で絞り込んでドメイン名以外(IP番号や () で囲まれている文字列等は削除)して example.com 系を削除してスペースを含んだ空白文字を削除してドメインが .com .net .cc .co.jp .or.jp .jp .org .info .biz .me .mobi .vc .tv .bz のどれかであるものを絞り込む