1824298 Members
5040 Online
109669 Solutions
New Discussion юеВ

link copy

 
Prashanth Waugh
Esteemed Contributor

link copy

Hi ,
can any body help me, how i can copy all files from one directory to
another . suppose i have a source directory called /abc/def in
which i have 20 files also some links are there. i want to copy all the files and links as it is from this direcory
to /xxx/yyy directory. can any body suggest me the way how to do it .
thanks
For success, attitude is equally as important as ability
6 REPLIES 6
Ivan Krastev
Honored Contributor

Re: link copy

use:
cp -r sourcedir targetdir

In manual page is written:
"Usually normal files and directories are copied. Character special devices, block special devices, network special files, named pipes, symbolic links, and sockets are copied, if the user has access to the file; otherwise, a warning is printed stating that the file cannot be created, and the file is skipped."

regards,
ivan
Prashanth Waugh
Esteemed Contributor

Re: link copy

Hi

Thanks for quick reply.

Suppose I am a superuser then it will show the error whole copying.
For success, attitude is equally as important as ability
Prashanth Waugh
Esteemed Contributor

Re: link copy

Hi Ivan,

The correct syntax is cp -R.

Thnks for ur help
For success, attitude is equally as important as ability
Prashanth Waugh
Esteemed Contributor

Re: link copy

thanks
For success, attitude is equally as important as ability
Mustafa Gulercan
Respected Contributor

Re: link copy

hi;
and more from man page,
If new_file is a link to an existing file with other links, cp
overwrites the existing file and retains all links. If copying a file
to an existing file, cp does not change existing file access
permission bits, owner, or group.
Ernesto Cappello
Trusted Contributor

Re: link copy

Hi atulkumar, you have to use this command:

cp -rH sourcedir targetdir

Best Regards.
Ernesto