6

I have found a reference using the following command

cp -rd  *  /folder_1/

and another one as

cp -dr * /folder_2/

Can you please advise what are these options "rd" or "dr"?

  • 3
    @moibrahim next time consider reading the manual , man cp or info cp or cp --help would have given you the same answers given below – user257256 Jul 13 '16 at 0:30
17

The order does not matter - you can give the options in any order

This combination will copy directories recursively (including all the contents) and copy symlinks as symlinks instead of copying the files they point to.

-d is only needed when using -r : it is used to override the default behaviour, which is not to follow symlinks when copying recursively

from info cp

‘-r’ ‘--recursive’ Copy directories recursively. By default, do not follow symbolic links in the source unless used together with the ‘--link’ (‘-l’) option; see the ‘--archive’ (‘-a’), ‘-d’, ‘--dereference’ (‘-L’), ‘--no-dereference’ (‘-P’), and ‘-H’ options.

‘-d’ Copy symbolic links as symbolic links rather than copying the files that they point to, and preserve hard links between source files in the copies. Equivalent to ‘--no-dereference --preserve=links’.

10

In many command line utilities, single-letter options can be written together. In your case, the longer form would be

cp -r -d  *  /folder_1/

which can be shortened to

cp -rd  *  /folder_1/

The other version

cp -dr  *  /folder_1/

is the same as

cp -d -r  *  /folder_1/

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.