LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Omitting directories... WHY??? (https://www.linuxquestions.org/questions/linux-newbie-8/omitting-directories-why-601795/)

vonedaddy 11-22-2007 11:21 PM

Omitting directories... WHY???
 
I am new to linux so excuse me if this is a dumb question.

I have a directory with about 8 subdirectories and 10 files in it.

I enter this command to copy the from the currect directory to /var/www/html

cp * /var/www/html

It omits all the directories and just copies the file?

Can anyone explain how to do this and why this does not work?

MS3FGX 11-22-2007 11:32 PM

I am not actually sure why cp's default action is to omit directories, it is just one of those things you have to get used to. To make it copy everything (directories, links, etc) give cp the -a switch. Like so:

Code:

cp -a ./* /var/www/html

wmakowski 11-22-2007 11:39 PM

You should specify either the -a or -r option when you want to copy directories. With no options cp will only copy files.

cp -a * /var/www/html will produce the result you desire.

Bill

vonedaddy 11-23-2007 12:34 AM

Quote:

Originally Posted by wmakowski (Post 2968081)
You should specify either the -a or -r option when you want to copy directories. With no options cp will only copy files.

cp -a * /var/www/html will produce the result you desire.

Bill



Thanks guys...

What is the difference between -a and -r ??

chrism01 11-23-2007 12:44 AM

man cp:


-a, --archive
same as -dpPR

-R, -r, --recursive
copy directories recursively


All times are GMT -5. The time now is 03:27 PM.