FileUtils.cp_r

M

Marc Heiler

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 ?
 
M

Marc Heiler

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

One has to add the '/.'

I think the docu could mention this:

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


Works.
 
M

matt neuburg

Marc Heiler said:
I was able to solve it with a 4 year old post of Nobu :)

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.
 
R

Ryan Davis

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):
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,743
Messages
2,569,478
Members
44,898
Latest member
BlairH7607

Latest Threads

Top