why can't I copy a directory without using -R ?
why can't I copy a directory without using -R ? It shows "cp: omitting directory" .
|
Hi,
cp is meant (without any options) to only work on the current working directory and _not_ on any subdirectories (with or without files). As stated in the man page, you need to use -R to copy recursively. This is the way it is implemented. Hope this helps. |
You can.
If you don't agree with the implementation, write your own. |
Because in Linux, directories don't actually contain files. They contain a list of "addresses" to files. So just directly copying the directory wouldn't copy the files inside.
The -R option tells cp that when it comes across a directory, it should create a new directory in the destination, and start copying files from the subdirectory. But personally, I think it's really stupid that cp doesn't recursively copy dirs by default, as if that's not what you always need and expect. |
All times are GMT -5. The time now is 04:30 PM. |