Created
July 21, 2020 06:01
-
-
Save mamemomonga/c42e01c7920fd1a07653b025c6d71ffc to your computer and use it in GitHub Desktop.
.ssh/cofnig の Hosts一覧を表示する
This file contains 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
#!/usr/bin/env perl | |
use strict; | |
use warnings; | |
use feature 'say'; | |
sub file_read { | |
my ($filename)=@_; my $buf=""; | |
open(my $fh,'<',$filename) || die "$filename - $!"; | |
local $/; $buf=<$fh>; | |
return $buf; | |
} | |
my $ssh_config=file_read("$ENV{HOME}/.ssh/config"); | |
foreach(split(/\n/,$ssh_config)) { | |
chomp; | |
if(/^Host (.+)$/) { say $1; } | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment