From: Robert Klemme Date: 2010-05-27T16:58:06+09:00 Subject: Re: file copy 2010/5/27 John Wu : > I am having a weird problem. I have the following code. > > require "fileutils" > > FileUtils.cp '/path/to/file.txt', '/path/to/archive/file-date.txt' > > File.open('/path/to/file.txt', 'w') You also need to close the file. > What I want to do is copy file.txt content to file-date.txt in a sub > directory, then reset file.txt to empty. > > But after I run the code above, both file.txt and file-date.txt are > reset to empty file. What am I missing here? Maybe /path/to/file.txt is a symlink or /path/to is liked to /path/to/archive or /path/to/file.txt is really the same as /path/to/archive/file-date.txt. Somehow I have the feeling you don't show the real code. Kind regards robert -- remember.guy do |as, often| as.you_can - without end http://blog.rubybestpractices.com/