From: Stu Date: 2013-05-07T11:48:08+09:00 Subject: Re: Files management with Ruby Poor kittens. Here let me rubify it for you so you don't get shot: #!/usr/bin/env ruby `cat B/*Today* >> A/Today` On Sun, May 5, 2013 at 11:24 PM, tamouse mailing lists wrote: > On Sun, May 5, 2013 at 3:47 PM, sdsd asda wrote: >> Hi there >> >> I am trying to build a script that does the following. Say there are two >> directories A and B. In A, there is the file called "Today". In >> directory B there are the files called "Today1", "Today2", "otherFile". >> I want to loop through directory A, open the file called "Today" and >> append all the files in Directory B that have the word "Today" in their >> file name. >> >> So where I am at is, I am trying to write a method first to just loop >> through Directory A and just add some text to the file called "Today". >> This is not working below. Can anyone tell me where I am going wrong? >> >> Much appreciated >> >> def append_data_to_daily_files >> Dir.entries('A').each do |file| >> next if !(file.match(/today/)) >> File.open(file, 'w') {|file| >> file.write("hello") >> file.close} >> end >> end >> >> -- >> Posted via http://www.ruby-forum.com/. >> > > I expect to be shot for this, but you know this works amazingly well: > > $ cat B/*Today* >> A/Today >