Last active
August 29, 2015 14:25
-
-
Save lostsnow/5447beae9063708f7b06 to your computer and use it in GitHub Desktop.
find vhost in nginx config files
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 characters
# http://lists.centos.org/pipermail/centos/2012-December/130613.html | |
while (<>) { | |
chomp(); | |
next if (m/^\s*#/); #comment | |
if ($enclosed) { | |
if (m/}/) {$enclosed = 0;} # end found | |
tr/}\;//d; #remove | |
push @servers, split(); #anything else on line | |
next; | |
} else { | |
next unless m/server_name/; | |
if (m/{/) { $enclosed = 1;} | |
if (m/}/) {$enclosed = 0;} #on same line? | |
s/server_name//; | |
tr/{}\;//d ; | |
push @servers,split(); | |
} | |
} | |
foreach (sort(@servers)) { print "$_\n";} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment