Operating System - Linux
1753320 Members
6466 Online
108792 Solutions
New Discussion юеВ

Re: really simple cp syntax question

 
SOLVED
Go to solution
Jay Bollyn
Honored Contributor

really simple cp syntax question

I would like to copy all files and directories in source location to target location. I'm sure my answer is in the man cp file, but I am having trouble. I thought it would be easiest to first be in the target directory, and then enter the following, using the period as the current dir:

cp /home/jbollyn/test .

My goal is to copy all files in the test dir into the current dir, and also copy all the child dirs and files of test to the target location, creating the complete dir structure.

So you see, I told you it was simple.

You can expect to see more bonehead questions from me, until I get up to speed (which might take awhile).

If it matters, I am running Debian 3.1.

J.

check Facebook
4 REPLIES 4
Victor Semaska_3
Esteemed Contributor
Solution

Re: really simple cp syntax question

Jay,

To do a copy including child dirs (known as a recursive copy) use the -r option. The command would be:

cp -r /home/jbollyn/test .

vic
There are 10 kinds of people, one that understands binary and one that doesn't.
Jay Bollyn
Honored Contributor

Re: really simple cp syntax question

Yeah, I thought 'recursive' might be involved in this, but I need to get more familiar with this term.

Even though this is just a test server, I really don't want to hose it just for fun.

I'm sure you are correct. I will check it out tomorrow from the office and post back.

J.

check Facebook
Ivan Ferreira
Honored Contributor

Re: really simple cp syntax question

You should use:

cp -Rp /home/jbollyn/test/* .

This will copy the content of the test directory without copying the test directory itself. The -p option preserves the file permissions.
Por que hacerlo dificil si es posible hacerlo facil? - Why do it the hard way, when you can do it the easy way?
Jay Bollyn
Honored Contributor

Re: really simple cp syntax question

thanks both
check Facebook