Ubuntu – Does cp not copy a specified folder


let's say that I have a following file structure:


Then, being in ~, I run this script:


And just an error happens:

cp: omitting directory ‘DIR1’

I understand why nothing from DIR1 gets copied (because I didn't use -r switch that would enforce recursion) but I'd expect the DIR1 folder itself copied to NEWDIR2 (so practically a creation of a new "NEWDIR2" in ~ or a creation of ~/NEWDIR2/DIR1).

Could someone explain to me why is my expectation wrong?

Best Answer

From the GNU info page for cp:

By default, 'cp' does not copy directories. However, the '-R', '-a', and '-r' options cause 'cp' to copy recursively by descending into source directories and copying files to corresponding destination directories.