I have the following code that reads mac addresses from a file and tries to append test at the end of the mac address.
File.open("/RubyDev/sort/mac1.txt",'r').each_line do |a|
puts "#{a} test"
end
This is the output:
SEP1C17D3C23929
test
SEP1C17D3C2B247
test
SEP1C17D3C24B98
test
I want it to be :
SEP1C17D3C23929 test
SEP1C17D3C2B247 test
SEP1C17D3C24B98 test
The problem is that the lines have a new-line (“\n”) on the end of them. To get rid of that, you can call
String#chomp: