I'm trying to create a script in ruby that reads through the files in a folder, and merges them into an individual file.
This is what i've come up with
File.open('authorized_keys','a') do |mergedfile|
@files = Dir.glob('/home/<user>/ruby_script/*.keys')
for file in @files
text = File.open(file, 'r').read
text.each_line do |line|
mergedfile << line
end
end
end
The idea is that the script will download public key files from github for our developers, merge them into an authorized_keys file which we'll then scp to our cloud servers.
The problem i'm having is that when the authorized_key file is generated, some of the ssh keys are on new lines, some are on the same line as others.
I've checked the downloaded files, and each key is on its' own line
How can I ensure that each key is on it's own line?
Thanks