Skip to content

Instantly share code, notes, and snippets.

@mamemomonga
Created July 21, 2020 06:01
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mamemomonga/1c7ff3f92758221e7f4ad975e2c7b89a to your computer and use it in GitHub Desktop.
Save mamemomonga/1c7ff3f92758221e7f4ad975e2c7b89a to your computer and use it in GitHub Desktop.
.ssh/cofnig の Hosts一覧を表示する
#!/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