Reputation: 21
Lets say I have a directory with name 'test folder' and when I tried to make a copy of it using ruby script it threw an error.
Here is what I tried:
irb(main):001:0>
`cp -R test\ folder folder`
Output:
usage: cp [-R [-H | -L | -P]] [-fi | -n] [-apvX] source_file target_file cp [-R [-H | -L | -P]] [-fi | -n] [-apvX] source_file ... target_directory => ""
Upvotes: 0
Views: 44
Reputation: 15954
Putting the folder name in apostrophes should work for you:
`cp -R 'test folder' folder`
But a more ruby-style method would be to use FileUtils.cp_r
:
require 'fileutils'
FileUtils.cp_r 'test folder', 'folder'
Both of these methods will copy the test folder
into the folder
so there will be a test folder
subdirectory created under folder
. If you want to copy the contents of the test folder
only, use 'test folder/.'
instead of 'test folder'
in the commands.
Upvotes: 3