Helpful Information
 
 
Category: UNIX Help
command for copy or duplicate a directory

what is the command for copy or duplicate a directory?

Hi!

the unix copy command is:
cp -dpR source(s) destination

never omit the destination! cp will try to overwrite the last file in your source directory!

-R says recursively, -p preserve attributes and i canīt remember -d... try "man cp" and "help cp"

One thing to watch for, depending on the Unix system you are using: cp -R directory/ newdirectory and cp -R directory newdirectory can do two different things. On some systems, the / can mean to copy the files in the directory to the new location, or it can mean to copy the entire directory tree.

For instance:

$ ls test/
file1
file2
file3
$ cp -R test newtest
$ ls newtest/
test
$ ls newtest/test/
file1
file2
file3

$ ls test/
file1
file2
file3
$ cp -R test/ newtest
$ ls newtest/
file1
file2
file3
The least ambiguous way to make sure it always works the ways you want:

$ mkdir newtest
$ cp -R test/* newtest/










privacy (GDPR)