Append a file to another file

Hi,

What is the best way to append the content from one file to another
file?

Thanks!

On Fri, May 28, 2010 at 10:34 AM, John Wu [email protected] wrote:

Hi,

What is the best way to append the content from one file to another
file?

Thanks!

Posted via http://www.ruby-forum.com/.

Just open the file in append mode, and write the contents of the file
you want to append to it.

eg:

to_append = File.read(“foo.txt”)
File.open(“bar.txt”, “a”) do |handle|
handle.puts to_append
end

Alex