View Full Version : Copying directories


NewComer
I know its a stupid question, but do I have to tar a directory then copy the tar file then untar the file inorder to copy a directory with all its subdirectories and files?

mohamed
No, you don't have to
Just use the -r option after cp, to make it recursive
cp -r directory1/ directory2

alaa
man cp
cp --help

uniball
cp -v -R /tmp/foo ~

man cp

NewComer
I read the man page before posting the thread but didn't know what recursively meant in this particular situation. I know what "recursively" mean but didn't think it meant files and directories within the directory.
Thanks again

whirlpool
take care when copying to copy file permitions too. Read the man page carefully.

alaa
it helps if you tell us that you already checked documentation.
we don't like to help lazy people.

BTW if you want to preserve permitions try cp -a

cheers,
Alaa