Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place! |
Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
 |
11-22-2007, 11:21 PM
|
#1
|
Member
Registered: Aug 2004
Location: Philadelphia,PA
Posts: 185
Rep:
|
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?
|
|
|
11-22-2007, 11:32 PM
|
#2
|
LQ Guru
Registered: Jan 2004
Location: NJ, USA
Distribution: Slackware, Debian
Posts: 5,852
|
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
|
|
|
11-22-2007, 11:39 PM
|
#3
|
Member
Registered: Oct 2003
Location: Ohio
Distribution: Fedora 25, 26, RHL 5.2
Posts: 560
Rep:
|
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
|
|
|
11-23-2007, 12:34 AM
|
#4
|
Member
Registered: Aug 2004
Location: Philadelphia,PA
Posts: 185
Original Poster
Rep:
|
Quote:
Originally Posted by wmakowski
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 ??
|
|
|
11-23-2007, 12:44 AM
|
#5
|
LQ Guru
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.x
Posts: 18,443
|
man cp:
-a, --archive
same as -dpPR
-R, -r, --recursive
copy directories recursively
|
|
|
All times are GMT -5. The time now is 04:11 AM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|