LinuxQuestions.org
Visit the LQ Articles and Editorials section
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
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

Reply
 
Search this Thread
Old 11-22-2007, 11:21 PM   #1
vonedaddy
Member
 
Registered: Aug 2004
Location: Philadelphia,PA
Posts: 177

Rep: Reputation: 17
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?
 
Old 11-22-2007, 11:32 PM   #2
MS3FGX
Guru
 
Registered: Jan 2004
Location: NJ, USA
Distribution: Slackware, Debian
Posts: 5,852

Rep: Reputation: 351Reputation: 351Reputation: 351Reputation: 351
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
 
Old 11-22-2007, 11:39 PM   #3
wmakowski
Member
 
Registered: Oct 2003
Location: Ohio
Distribution: Fedora 18, 19, RHL 5.2
Posts: 546

Rep: Reputation: 43
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
 
Old 11-23-2007, 12:34 AM   #4
vonedaddy
Member
 
Registered: Aug 2004
Location: Philadelphia,PA
Posts: 177

Original Poster
Rep: Reputation: 17
Quote:
Originally Posted by wmakowski View Post
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 ??
 
Old 11-23-2007, 12:44 AM   #5
chrism01
Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.5, Centos 5.10
Posts: 16,301

Rep: Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037
man cp:


-a, --archive
same as -dpPR

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


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Omitting Directory Error carlosinfl Linux - General 3 03-27-2007 04:21 PM
omitting icons from PLACES or SYSTEM menus of Fedora 6 guy_ripper Linux - Software 0 01-04-2007 07:52 AM
omitting space in shell script Fond_of_Opensource Linux - Newbie 10 11-18-2006 09:18 AM
cp: omitting error jsolanky Linux - Software 10 11-28-2004 09:09 AM
formating console output (omitting parts you do not want) bpk Linux - Newbie 6 06-10-2004 07:32 PM


All times are GMT -5. The time now is 06:45 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration