Last active
August 29, 2015 14:01
-
-
Save AntelopeSalad/4414525c38fcffe1979b to your computer and use it in GitHub Desktop.
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
hosts_file = File.readlines('/path/to/hosts') | |
group_names = [] | |
host_names = [] | |
hosts_file.each do |line| | |
line.chomp! | |
first_char = line[0] | |
last_char = line[-1, 1] | |
group_names << line if first_char == '[' && last_char == ']' | |
host_names << line if line.count('.') >= 1 | |
end | |
p 'group names:' | |
p group_names | |
p 'host names:' | |
p host_names |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment