# FileUtils.cp\_r

**URL:** <https://www.ruby-forum.com/t/fileutils-cp-r/143465>\
**Category:** Ruby\
**Created:** [July 18, 2008, 10:42pm UTC](https://www.ruby-forum.com/t/fileutils-cp-r/143465 "2008-07-18T22:42:00Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![quik77](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/q/dec6dc/32.png) [@quik77](https://www.ruby-forum.com/u/quik77)\
**Post date:** [July 18, 2008, 10:42pm UTC](https://www.ruby-forum.com/t/fileutils-cp-r/143465/1 "2008-07-18T22:42:00Z")

</div>

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 ?

---

<div class="post-metadata">

**Author:** ![quik77](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/q/dec6dc/32.png) [@quik77](https://www.ruby-forum.com/u/quik77)\
**Post date:** [July 18, 2008, 10:45pm UTC](https://www.ruby-forum.com/t/fileutils-cp-r/143465/2 "2008-07-18T22:45:41Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![quik77](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/q/dec6dc/32.png) [@quik77](https://www.ruby-forum.com/u/quik77)\
**Post date:** [July 19, 2008, 6:30am UTC](https://www.ruby-forum.com/t/fileutils-cp-r/143465/3 "2008-07-19T06:30:37Z")

</div>

Marc H. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

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

---

<div class="post-metadata">

**Author:** ![quik77](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/q/dec6dc/32.png) [@quik77](https://www.ruby-forum.com/u/quik77)\
**Post date:** [July 19, 2008, 8:37pm UTC](https://www.ruby-forum.com/t/fileutils-cp-r/143465/4 "2008-07-19T20:37:03Z")

</div>

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