FileUtils.cp_r

Hi,

I have all of the program “atk” in one directory.

I want to recursively copy this to /usr.

This commandline works in bash shell:

cp -r /Programs/Atk/Current/* /usr/

These examples in Ruby do not work:

FileUtils.cp_r ‘/Programs/ATK/Current/’, ‘/usr’
FileUtils.cp_r ‘/Programs/ATK/Current/’, ‘/usr/’
FileUtils.cp_r ‘/Programs/ATK/Current’, ‘/usr/’

(They all copy Current/ instead of what is inside Current/* )

And using ‘*’ like so

FileUtils.cp_r ‘/Programs/ATK/Current/*’, ‘/usr/’

does neither work.

Does anyone have an idea how to grab the * content
under Current/ and copy that to /usr ?

I was able to solve it with a 4 year old post of Nobu :slight_smile:

One has to add the ‘/.’

I think the docu could mention this:

FileUtils.cp_r( ‘/Programs/ATK/Current/’+"/.", ‘/usr/’)

Works.

Marc H. [email protected] wrote:

I was able to solve it with a 4 year old post of Nobu :slight_smile:

One has to add the ‘/.’

I think the docu could mention this:

The docs do say exactly that, I think:

If you want to copy all contents of a directory instead of the

directory itself, c.f. src/x → dest/x, src/y → dest/y,

use following code.

FileUtils.cp_r ‘src/.’, ‘dest’

m.

On Jul 18, 2008, at 13:40 , Marc H. wrote:

I think the docu could mention this:

FileUtils.cp_r( ‘/Programs/ATK/Current/’+"/.", ‘/usr/’)

there is a whole well documented paragraph of code on it (two in fact,
if you count the glob one):