From: luisbebop Date: 2008-10-26T00:08:19+09:00 Subject: Re: Join all text files in a folder, with a single line of Ruby code 'Case I'm learning Ruby , and I wanna see some snippets to make some tasks in a single line of Ruby code. Directly from prompt is not funny! On Oct 25, 12:40 pm, Robert Klemme wrote: > On 25.10.2008 13:56, Brian Candler wrote: > > > luisbebop wrote: > >> I did a single line of code in Ruby, which joins all text files in a > >> folder to a bigfile. I got some tests, and it's works! > >> Does anyone knows a better way, or other 'Ruby Way' to do that ? > > >> File.open('bigfile','w') { |mergedFile| Dir.glob("*.txt").each { | > >> file| File.readlines(file).each { |line| mergedFile << line } } } > > > system("cat *.txt >bigfile") > > Why not directly invoke "cat" from the shell prompt? :-) > > Kind regards > >         robert